Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added energy and power density to output #80

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

mglasser16
Copy link
Contributor

Also allows setting the radius for each current individually. Still messy, not for merging into main batcan.

Copy link
Contributor

@decaluwe decaluwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mglasser16 -- this is very close. There is a main question of what we want to do with these numbers (how we want to save them). Really there is just a single number for the energy and power density, which isn't really amenable to saving with the solution vectors.

Two options:

  • We could calculate those single numbers and save them in some separate text / ascii file.
  • We could save the cumulative power / energy densities at each time step (I think this is what you currently have for energy density, but not for power density), and save them with the solution vector arrays. Then the number we actually want is just the final number, but maybe someone would be interested with how it evolves, as well?

I'm good with either. The 2nd option might be simpler / more direct.

# current = params['i_ext']
# # Split the current from the units:
# i_ext, units = current.split()
self.surf_to_volume = 1.23224E-11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a. Is this setable from the input file?

b. This number seems like it is inverted. A/V should be proportional to 1/r, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not using this for anything, so I'll remove this line

simulations/CC_cycle.py Outdated Show resolved Hide resolved
@@ -91,14 +93,23 @@ def terminate_check(t, SV, SVdot, return_val, inputs):
i_data = currents[i]*np.ones_like(solution.values.t)
cycle_number = int(i+1-equil)*np.ones_like(solution.values.t)
cycle_capacity = 0.1*solution.values.t*abs(i_data)/3600
voltage = solution.values.y.T[-7]
power_density = voltage*i_data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a single number in the end, which is a time-weighted average of each of these values.
Also, I think you can do the work below without a loop, by just slicing the arrays.

delta_t = solution.values.t[1:] = solution.values.t[:-1]
energy_density = np.sum(voltage[1:],delta_t)*currents[I]/3600 # should be mAh/cm2, but please check my math
power_density = 3600*energy_density / solution.values.t[-1] #Again, check my unit conversion.

One question is: how do we want to store/save these? It doesn't really fit in the array of solution vectors.

Maybe write a txt file or a separate csv that has metrics like this?


# Append the current data array to any preexisting data, for output.
# If this is the first step, create the output data array.
if i: # Not the first step. 'data_out' already exists:
# Stack the times, the current at each time step, and the solution
# vector at each time step into a single data array.
SV = np.vstack((solution.values.t+data_out[0,-1], cycle_number,
i_data, cycle_capacity, solution.values.y.T))
i_data, cycle_capacity, power_density, energy_density, solution.values.y.T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - there is just one power density and one energy density, really, per simulation. Do we store them separately?

Another idea is we just calculate the cumulative power and energy densities, as a function of time, and the final value in this array is the single number that I calculate above. Then we can store it with the solution, and the "final number" is easily extractable as the last element in the array...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, if we do save the cumulative values, I think the power density still requires some editing from what you currently have. But it likely would involve a for loop, so my current approach doesn't work either. More like a blend of our two approaches.

# (2) cycle number, (3) current density(A/cm2) , and (4) Capacity (mAh/cm2)
SV_offset = 4
# (2) cycle number, (3) current density(A/cm2) , (4) Capacity (mAh/cm2) and (5) power density and (6) energy density
SV_offset = 6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending how we answer above, either keep this as is (if we store cumulative densities), or re-set to 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants