-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
Improve print_parameter_info
functionality
#3361
Comments
What case do you have in mind for this particular functionality? At the moment, models have the |
@brosaplanella Where is the This is a very helpful sounding function that I never knew existed. So while it probably satisfies this issue, it's not surprising that it might be missed. |
Thanks for your quick reply @brosaplanella. As I understand, parameter set, model and simulation each has a subset of battery parameters, and these battery parameters interact somehow in the background when calling simulations. For instance: I assume that calling |
I just realised that it is not documented in the docs (opened #3392 for this), but it is demonstrated in this example https://docs.pybamm.org/en/latest/source/examples/notebooks/parameterization/parameter-values.html#Printing-parameter-values |
I think one way to improve It is a fairly simple issue which is good for new contributors, if you want to give it a go. Let us know if you need any help! |
print_parameter_info
functionality
Hi! I added a new method def parameter_info(self, param_class, param_type):
parameter_info = ""
parameters = self._find_symbols(param_class)
for parameter in parameters:
if isinstance(parameter, pybamm.FunctionParameter):
if parameter.name not in parameter_info:
input_names = "'" + "', '".join(parameter.input_names) + "'"
parameter_info += (
f"{parameter.name} ({param_type} with input(s) {input_names})\n"
)
elif isinstance(parameter, pybamm.InputParameter):
if not parameter.domain:
parameter_info += f"{parameter.name} ({param_type})\n"
else:
parameter_info += (
f"{parameter.name} ({param_type} in {parameter.domain})\n"
)
elif isinstance(parameter, pybamm.Parameter):
parameter_info += f"{parameter.name} ({param_type})\n"
return parameter_info
def print_parameter_info(self):
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)
self._parameter_info += parameter_info
print(self._parameter_info) The code works as intended. It also passed the pre-commit checks. If there are any suggestions for improvement or if additional modifications are needed, please let me know. I'm open to making any necessary revisions. NOTE: This would be my first contribution (both to PyBaMM and an organisation in general) so I would appreciate feedback or suggestions! |
Description
Pybamm has an api to access parameter sets. When selecting a model (e.g. SPM), some, not all of the parameters of the set are used. It would be nice to have a method to pull only the parameters of the chosen model.
Motivation
No response
Possible Implementation
To have independent apis for parameter sets and models. E.g.
Additional context
No response
The text was updated successfully, but these errors were encountered: