MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
265 stars 67 forks source link

Add API method for inspection of user-defined variables #182

Open sammousavi opened 1 month ago

sammousavi commented 1 month ago

There is no direct function in the Model class to view variables (similar to parameters). It would be great to have a function like model.variables() in addition to model.parameters().

john-hen commented 1 month ago

Hi. I think that's fine. It can be added if someone wants to put the work in.

Personally, I never saw a use case for querying the variables. Like parameters, those we need to automate parameter sweeps. Or even optimization schemes. What are the variables good for? From an automation perspective. (Inside the Comsol model itself they're obviously useful.)

Do you plan to work on this? The demo model (from the tutorial) doesn't define any custom variables. The first step would be to add some, as an example, to that model. Then write a demo script that queries them. So that we see what the new function (method of the Model class) would do. We're eventually going to need something like that anyway, as I'm not adding library code that doesn't come with automated tests.

If you don't want to contribute the code, we can leave this issue open as a feature request.

john-hen commented 1 month ago

Feature request it is...