-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Better ProcessedVariable #760
Comments
Actually, solution = solver.solve(model, t_eval)
voltage = solution["Terminal voltage [V]"].entries # or .data? for the matrix
voltage_at_t1 = solution["Terminal voltage [V]"](t=1) |
This is going to break a lot of existing functionality so would be good to brainstorm ideas before getting started |
it would also be good to be able to access variables in a more user-friendly way than just having a huge list of variables. maybe they could be organised by submodel and domain, e.g. something like |
Following @rtimms point, if we go this way it would be good to split them between dimensional and dimensionless given that most of them have both versions. |
I like the idea of solution having the processed variables in though |
Ok, those two things should definitely be possible but sound like separate issues |
I see. So you mean doing what you suggest on the first post as opposed to the following?
|
Yeah exactly |
Not sure what would be the best option as I am not familiar with what PyBaMM is doing when processing a variable. The second approach you suggested, the one with the solution containing the processed variables might be too slow and memory confusing if the solution has a lot of data points. Given that, if I remember correctly, the mesh is needed for plotting as well, wouldn't it be better to store the mesh in the solution so then we can just do
|
alternatively, this could all be handled via the simulation object? if everything lives under the umbrella of that then we could do |
Yes good point, what would be nice though is it we could just do |
Yeah simulation makes it easier but would be good if it was also less clunky outside of that |
I agree with @tinosulzer. Could we make the On the other hand, if this new definition of |
Yes that sounds like the best way forward. We could also have the default being "don't process any variables in solution" and then have a |
I was chatting with Tino and also suggested putting process variables in the simulation. I also like the idea of having dictionaries of dictionaries for breaking up the variables like a tree structure. My main issue at first was that I wasn't sure why I couldn't just see the data nicely in the solution. Can you please explain the main reason why processed variables exist. If it's to do interpolation I feel like that should just be a separate post process or some secondary option where if you pass in a time step it does it and if not it just used the solution time steps. If it's to help with some of the weird and whacky stuff going on with having an SPM that is only really solved at one point but shown as if it were applied along x then it's more tricky... I still don't fully understand what the different models are doing in this respect. I think the most important thing to get right is passing the data back in a consistent way when you have the N+1D models. I guess you could have up to 5 dimensions of data? Don't know if that helps or makes sense. It also has to be consistent with inputs and depending on where they are going to be stored it would be nice to get that as user friendly as possible |
I also feel like it's handy to basically have solution as close to an array type data as possible without loading it up with methods and would prefer the simulation class to have that functionality. It's good that you can just append time steps for example and it seems to work. From a saving and loading perspective it's better to save raw data as class definitions change (all the time) then pickled files get unreadable fast |
Processed variable does 2 things:
Would the following be ok? solution["Voltage"] # this is the ProcessedVariable class, with interpolation
solution["Voltage"].data # gives the n-dimensional matrix you want
solution.data # gives dictionary of n-dimensional arrays
solution.save(filename) # saves only the data arrays, to a dictionary |
@TomTranter has pointed out several times that processed variables need a rethink and I agree. In particular we need to strike the balance between having to pass lots of inputs to ProcessedVariable and storing too much inside the variable object itself.
However, we could switch to something better by doing e.g.
where the mesh is stored in the variable and
.process
created aProcessedVariable
.Or something else? Like
The text was updated successfully, but these errors were encountered: