-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Print parameter info by submodel #1500
Comments
Be good to also add a table that lists parameters with a tick against each submodel |
Note you can do import pybamm
model = pybamm.lithium_ion.SPM()
submodel = model.submodels["positive primary particle"]
submodel.print_parameter_info() |
HI @tinosulzer Can you assign this to me? I'd be more than happy to work on this. |
Hi @rtimms I see you already implemented the print_parameter_info() above. DO i have to look for the implementation into this page - https://github.com/pybamm-team/PyBaMM/blob/develop/pybamm/models/submodels/base_submodel.py |
At the moment you can do |
Just bit of clarification. With the help of above mentiioned example. I tried printing.
On using
So, I want to knoiw that when we write the |
Hi @rtimms Any update on this yet? |
The output of for name, submodel in model.submodels.items():
print(name, "submodel parameters:")
submodel.print_parameter_info() |
Hello! I have tried solving this issue by implementing @rtimms method of printing the parameters submodel-wise in my code.
def print_parameter_info(self, by_submodel=False):
"""Prints all the extracted parameter information of the model(s)"""
try:
if by_submodel:
if not hasattr(self, 'submodels'):
print("ERROR: Model has no submodels.")
return
for submodel_name, submodel in self.submodels.items():
print(f"'{submodel_name}' submodel parameters:")
submodel.print_parameter_info()
else:
self._parameter_info = ""
parameter_types = [
("Parameter", pybamm.Parameter),
("inputParameter", pybamm.InputParameter),
("FunctionParameter", pybamm.FunctionParameter),
]
for param_type, param_class in parameter_types:
parameter_info = self.parameter_info(param_class, param_type)
if parameter_info is not None:
self._parameter_info += parameter_info
else:
print(f"WARNING: parameter_info is NONE for {param_type}")
print(self._parameter_info)
except Exception as e:
print(f"ERROR in print_parameter_info: {e}") The feature works as intended, and has passed the pre-commit checks. |
NOTE: import pybamm
model = pybamm.lithium_ion.SPM()
submodel = model.submodels["positive primary particle"]
model.print_parameter_info() OUTPUT:
Whereas, when I set import pybamm
model = pybamm.lithium_ion.SPM()
submodel = model.submodels["positive primary particle"]
model.print_parameter_info(by_submodel=True) OUTPUT:
Here are the inferences I gathered from the output:
I am new to the codebase and am still learning about all the functionalities. I would be happy if someone can walk me through the required information for this issue. Thank you! |
When printing parameter info, add an option to separate by submodel name (with repetitions between submodels).
This might require storing the parameters when the submodel is created.
The text was updated successfully, but these errors were encountered: