Store model "parameters" in a dictionary in Project object #1985
Replies: 2 comments
-
I see a lot of value in this, since it is a nice way to address 'constants' as well, which was considered in #717, but ignored due to the challenges. We'd need to think about the implementation a bit though. |
Beta Was this translation helpful? Give feedback.
-
You could actually do this with the code as it is now, just write a new model that accepts "parameters", and then looks up the values from the Project, assuming you've manually added the 'parameters' attribute as a dictionary. A sample model would look like: proj.parameters = {} # Add your own parameters attr
proj.parameters['exchange_current_density'] = 1e-6 # Populate it
...
# Define custom model
def model(target, ... , i_0='exchange_current_density'):
...
val = a*b*target.project.parameters[i_0] # Use param in model
return val We could / should officially support this by adding an empty |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There are two types of model parameters: those that could have a spatial distribution, and those that are constant across the entire domain. For instance, the "exchange current density", j0, is typically constant, whereas "temperature" (in a mass transfer simulation) could vary pore by pore.
Normally, we store the dictionary key of that parameter in the pore-scale model, so the values can be dynamically changed without the need to re-store the values in the model. Ideally, we don't want to do that for constant parameters, as they take up
Np
by 1ndarray
whereas they can simply be stored asfloat
.Currently, we pass the exact value of that parameter to the pore-scale model, which will then be hard-coded in the model. So, every time we want to "change" that parameter, let's say for a parametric study for instance, we need to re-instantiate the model with the new value, which is not convenient.
Instead, we can simply store such parameters in the
Project
object, and pass a reference to the pore-scale model. This makes it much easier to keep track of parameters and is less error-prone.Beta Was this translation helpful? Give feedback.
All reactions