Skip to content
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

OpenMDAO recorder #370

Closed
AleSgueglia opened this issue Jul 26, 2021 · 3 comments
Closed

OpenMDAO recorder #370

AleSgueglia opened this issue Jul 26, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@AleSgueglia
Copy link

Hello,
is there any possibility today to use the OpenMDAO recorder for tracking the variables within FAST OAD?
I found it very useful when working in OpenMDAO to log the results, but it seems that in FAST OAD there is not the possibility to use it yet.

Thanks in advance for the reply.

Regards,
Alessandro Sgueglia

@AleSgueglia AleSgueglia added the enhancement New feature or request label Jul 26, 2021
@christophe-david
Copy link
Contributor

Hello,

You are right, there is no FAST-OAD-specific way to configure an OpenMDAO recorder, but you may still do it using your knowledge of OpenMDAO, and a part of FAST-OAD that we did not advertise yet, but is nonetheless part of the official (thus maintained) API of FAST-OAD.

Assuming you have a configuration file, you can do:

import fastoad.api as oad
import openmdao.api as om


conf = oad.FASTOADProblemConfigurator("path/to/your/conf_file.yml") # reads the configuration file
conf.write_needed_inputs("your/data_source.xml") # you may skip this step if you already generated your input file
problem = conf.get_problem(read_inputs=True) # here you get an OpenMDAO problem (with only a few additions)

# Here you may add your recorder using the OpenMDAO way
recorder = om.SqliteRecorder("record.sqlite")
problem.model.add_recorder(recorder)
problem.model.recording_options['includes'] = ['*']

# You run the problem normally
problem.setup()
problem.run_model()

# To get FAST-OAD outputs, you have to use the method we have added
# to our slightly modified Problem class: 
problem.write_outputs()

Please let me know it you can work with that.

And if you want a more straight-forward solution, I would be interested to have some suggestions on the way we should make such feature available. Would you have this settings in the configuration file? What syntax you think would be useful?

@AleSgueglia
Copy link
Author

Hello,
thank for the reply: indeed it has been useful to me to discover this nice feature!

To answer your final question, in my opinion a good way to implement the recorder in FAST OAD would be to add it as an option that can be declared in the configuration file, in a similar manner as the optimisation driver.

Best regards,
Alessandro

@christophe-david
Copy link
Contributor

Thanks for the feedback.

To answer your final question, in my opinion a good way to implement the recorder in FAST OAD would be to add it as an option that can be declared in the configuration file, in a similar manner as the optimisation driver.

I take the occasion to write some thoughts about that:

Actually, as you know, recorders in OpenMDAO are not set like the optimisation driver. You can set recorders for problem, driver, solvers, or systems. And strictly speaking, add_recorder() allows to define several recorders for a same entity. But we may forget this last possibility and simply use a recorder = ... syntax in the configuration file that could be placed at the desired level in the configuration file.
After that, we should handle the recording_options, which will probably have to be a structure on its own, like:

recording_options:
  excludes : 
    - private:*
    - *useless*
  record_inputs : false

And to be complete, we will have to allow to set a case prefix when running the problem.

@christophe-david christophe-david pinned this issue Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants