-
Notifications
You must be signed in to change notification settings - Fork 1
Thermoelastic3d #209
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
base: main
Are you sure you want to change the base?
Thermoelastic3d #209
Conversation
g-braeunlich
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs seem to be missing (see docs/README.md)
| xi_nodes = np.array([-1, 1, 1, -1, -1, 1, 1, -1], dtype=float) | ||
| et_nodes = np.array([-1, -1, 1, 1, -1, -1, 1, 1], dtype=float) | ||
| ze_nodes = np.array([-1, -1, -1, -1, 1, 1, 1, 1], dtype=float) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| xi_nodes = np.array([-1, 1, 1, -1, -1, 1, 1, -1], dtype=float) | |
| et_nodes = np.array([-1, -1, 1, 1, -1, -1, 1, 1], dtype=float) | |
| ze_nodes = np.array([-1, -1, -1, -1, 1, 1, 1, 1], dtype=float) | |
| xi_nodes = np.array([-1, 1, 1, -1, -1, 1, 1, -1]) | |
| et_nodes = np.array([-1, -1, 1, 1, -1, -1, 1, 1]) | |
| ze_nodes = np.array([-1, -1, -1, -1, 1, 1, 1, 1]) |
np.float64 / float is default
| import numpy as np | ||
|
|
||
|
|
||
| def fe_melthm_3d(nu: float, e: float, k: float, alpha: float) -> tuple[np.ndarray, np.ndarray, np.ndarray]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def fe_melthm_3d(nu: float, e: float, k: float, alpha: float) -> tuple[np.ndarray, np.ndarray, np.ndarray]: | |
| def fe_melthm_3d(nu: float, e: float, k: float, alpha: float) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]: |
This requires:
from numpy.typing import NDArraySimilarly below
| class FeaModel3D: | ||
| """Finite Element Analysis (FEA) model for coupled 3D thermoelastic topology optimization.""" | ||
|
|
||
| def __init__(self, *, plot: bool = False, eval_only: bool | None = False) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def __init__(self, *, plot: bool = False, eval_only: bool | None = False) -> None: | |
| def __init__(self, *, plot: bool = False, eval_only: bool = False) -> None: |
| @@ -0,0 +1,47 @@ | |||
| """Module for plotting a 3D thermoelastic design with napari.""" | |||
|
|
|||
| from __future__ import annotations | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from __future__ import annotations |
Already requiring python >= 3.10. So this is no longer needed.
Also, this is in conflict with our constraint api which relies on the types in signatures, which __future__.annotations will convert into strings.
| def __init__(self, seed: int = 0) -> None: | ||
| """Initializes the thermoelastic3D problem. | ||
|
|
||
| Args: | ||
| seed (int): The random seed for the problem. | ||
| """ | ||
| super().__init__(seed=seed) | ||
|
|
||
| def reset(self, seed: int | None = None) -> None: | ||
| """Resets the simulator and numpy random to a given seed. | ||
|
|
||
| Args: | ||
| seed (int, optional): The seed to reset to. If None, a random seed is used. | ||
| """ | ||
| super().reset(seed) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def __init__(self, seed: int = 0) -> None: | |
| """Initializes the thermoelastic3D problem. | |
| Args: | |
| seed (int): The random seed for the problem. | |
| """ | |
| super().__init__(seed=seed) | |
| def reset(self, seed: int | None = None) -> None: | |
| """Resets the simulator and numpy random to a given seed. | |
| Args: | |
| seed (int, optional): The seed to reset to. If None, a random seed is used. | |
| """ | |
| super().reset(seed) |
Redundant
Description
This is the second version of this pull request, as the first didn't pass the mypy or ruff checks. I think mypy still fails because of a line in heatcondiction3d, but I didn't want to be both adding this problem and fixing the heatconduction3d one.
This pull request contains the entire codebase for the thermoelastic3d problem. It is quite similar to the thermoelastic2d problem with some minor additions. Two new dependencies were added to the pyproject.toml file. One outstanding issue to be resolved is the render function. I am using napari to visualize the 3d designs, so I am returning the napari np.ndarray in this function as I couldn't find a figure class like matplotlib. Besides this, everything seems ok for the time being.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Checklist:
pre-commitchecks withpre-commit run --all-filesruff check .andruff formatmypy .Reviewer Checklist: