Skip to content

Deduplicate constraints and conditions#141

Merged
g-braeunlich merged 4 commits into
mainfrom
90-conditions-refactor
Aug 7, 2025
Merged

Deduplicate constraints and conditions#141
g-braeunlich merged 4 commits into
mainfrom
90-conditions-refactor

Conversation

@g-braeunlich
Copy link
Copy Markdown
Collaborator

No description provided.

@g-braeunlich g-braeunlich linked an issue Jun 10, 2025 that may be closed by this pull request
@g-braeunlich g-braeunlich self-assigned this Jun 10, 2025
@g-braeunlich g-braeunlich requested a review from ffelten June 10, 2025 09:25
@g-braeunlich g-braeunlich force-pushed the 90-conditions-refactor branch from 7002eb0 to 86539ce Compare June 10, 2025 12:58
Copy link
Copy Markdown
Collaborator

@ffelten ffelten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks way nicer 👍, good job!
My main concern: the API break with conditions_keys -- should be easy to fix.

Also, I'm wondering if we should not define conditions in another file to reduce the size of the v0 files? This would also solve the circular dependency issues when you want to type function parameters in backend with the actual config type.

Comment thread engibench/core.py
Comment thread engibench/core.py
class Config(Conditions):
"""Structured representation of configuration parameters for a numerical computation."""

alpha: Annotated[float, bounded(lower=0.0, upper=10.0).category(THEORY)] = 0.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think alpha being part of the config is a bit weird. Here is the info I have in mind:

  • Alpha should be part of the design from an engineering perspective (angle of attack)
  • The way we pass alpha to the simulator is via the templating, which takes the config and conditions dict.
  • Having alpha in these dataclasses allows to check conditions, although we could include it in the designs and check conditions on the designs.

I'm not sure how to deal with this: it seems like putting alpha in these dicts makes "implementation sense" but does not make "domain-specific sense". I don't know if I'm clear at all.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont mind at all.
@cashend What is your point on this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cashend quick ping on this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think alpha being part of the config is a bit weird. Here is the info I have in mind:

Alpha should be part of the design from an engineering perspective (angle of attack)
The way we pass alpha to the simulator is via the templating, which takes the config and conditions dict.
Having alpha in these dataclasses allows to check conditions, although we could include it in the designs and check conditions on the designs.
I'm not sure how to deal with this: it seems like putting alpha in these dicts makes "implementation sense" but does not make "domain-specific sense". I don't know if I'm clear at all.

After some thought, I think this makes sense. I suggest we just keep alpha as a design variable. I also think keeping the constraint warning might be good though in case people try to use crazy AoAs.

Comment thread engibench/problems/airfoil/v0.py
Comment thread engibench/problems/airfoil/v0.py Outdated
Comment thread engibench/problems/beams2d/v0.py Outdated
Comment thread engibench/problems/beams2d/v0.py Outdated
("length", self.length),
)
self.config = self.Config(**kwargs)
self.volume = self.config.volume
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well remove self.volume and replace by self.config.volume everywhere to avoid duplicates?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MiladHB Would that break some workflow? I.e. does any workflow access problem.volume directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MiladHB quick ping

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Gerhard, Sorry for the late reply. If I understand correctly, changing self.volume to self.config.volume should not cause any problems since the simulation codes do not have access to problem.volume.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess same applies for resolution and length?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are similar variables.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Changed now in 2d and 3d

Comment thread engibench/problems/beams2d/v0.py Outdated
Comment thread tests/test_constraint.py
@g-braeunlich g-braeunlich force-pushed the 90-conditions-refactor branch 2 times, most recently from afa937e to a9864d6 Compare June 12, 2025 10:41
@g-braeunlich g-braeunlich force-pushed the 90-conditions-refactor branch 5 times, most recently from 9e0c085 to a229a66 Compare July 11, 2025 06:38
@g-braeunlich g-braeunlich force-pushed the 90-conditions-refactor branch from a229a66 to f0bcc3d Compare July 29, 2025 08:17
@ffelten
Copy link
Copy Markdown
Collaborator

ffelten commented Aug 6, 2025

What is the status on this? It's been hanging for while now 😅

@g-braeunlich
Copy link
Copy Markdown
Collaborator Author

To my knowledge, every comment should be addressed now.
There is one mypy test failing, but this is probably due to some other change in power electronics.

@ffelten
Copy link
Copy Markdown
Collaborator

ffelten commented Aug 6, 2025

To my knowledge, every comment should be addressed now. There is one mypy test failing, but this is probably due to some other change in power electronics.

That, or a new version of mypy that has found a new potential error. I believe we can fix these ones in this PR and merge.

@g-braeunlich g-braeunlich force-pushed the 90-conditions-refactor branch from f0bcc3d to cd39769 Compare August 7, 2025 09:01
@g-braeunlich
Copy link
Copy Markdown
Collaborator Author

OK. Should be fixed now

@g-braeunlich g-braeunlich merged commit 0b351a9 into main Aug 7, 2025
10 checks passed
@g-braeunlich g-braeunlich deleted the 90-conditions-refactor branch August 7, 2025 18:34
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 this pull request may close these issues.

Conditions refactor

5 participants