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

Generated code: specification of units #82

Closed
christophe-david opened this issue Jun 22, 2021 · 6 comments · Fixed by #84
Closed

Generated code: specification of units #82

christophe-david opened this issue Jun 22, 2021 · 6 comments · Fixed by #84

Comments

@christophe-david
Copy link

Hello,
in generated code for OpenMDAO, I would greatly appreciate if units could be specified in following methods:

  • set_input_defaults()
  • add_design_var()
  • add_objective()
  • add_constraint()
@relf
Copy link
Collaborator

relf commented Jun 28, 2021

You did not mention add_input and add_output at component level, though WhatsOpt could enforce it here too. Whats is the rationale? Does it let the component implementation use compatible units?

@christophe-david
Copy link
Author

Actually, I don't need any change in these methods in my use case, as I use my own implementation of disciplines. But for sake of consistency, I guess you may declare units in these methods as well.

@relf relf closed this as completed in #84 Jun 28, 2021
@relf
Copy link
Collaborator

relf commented Jun 28, 2021

add_input and add_output are in the setup in the base files. Do you override this method when you use your implementations? If not how does it work if you use compatible but different units than the ones specified by WhatsOpt in the setup?

@christophe-david
Copy link
Author

add_input and add_output are in the setup in the base files. Do you override this method when you use your implementations?

I override the create_*() methods to use my own implementations of the disciplines, that do not inherit from the base classes. Therefore, the generated base classes for these disciplines are not used. Of course, I know that in such case, I am responsible for keeping my inputs and outputs consistent.

If not how does it work if you use compatible but different units than the ones specified by WhatsOpt in the setup?

Currently, it does not work, that's the point 😁. But once the inputs will have been declared with proper units, OpenMDAO will gracefully do the conversion, and then, it will be great!

@relf
Copy link
Collaborator

relf commented Jun 28, 2021

Ok, I will also add units at component level (it was my concern in the first place it gets in the way if I do). And you can test right now as the feature is deployed.

@christophe-david
Copy link
Author

Many thanks. I will test that very soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants