-
Notifications
You must be signed in to change notification settings - Fork 6
fix(thermoelastic2d): align column names with v1 dataset #247
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,7 +119,7 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str | |
| Args: | ||
| bcs (dict[str, any]): A dictionary containing boundary conditions and problem parameters. | ||
| Expected keys include: | ||
| - 'volfrac' (float): Target volume fraction. | ||
| - 'volume_fraction_target' (float): Target volume fraction. | ||
| - 'fixed_elements' (np.ndarray): NxN binary array encoding the location of fixed elements. | ||
| - 'force_elements_x' (np.ndarray): NxN binary array encoding the location of loaded elements in the x direction. | ||
| - 'force_elements_y' (np.ndarray): NxN binary array encoding the location of loaded elements in the y direction. | ||
|
|
@@ -146,7 +146,7 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str | |
| nelx = fe_h - 1 | ||
| nely = fe_w - 1 | ||
|
|
||
| volfrac = bcs["volfrac"] | ||
| volfrac = bcs["volume_fraction_target"] | ||
| n = nely * nelx # Total number of elements | ||
|
Comment on lines
147
to
150
|
||
|
|
||
| # OptiSteps records | ||
|
|
@@ -285,7 +285,7 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str | |
| return { | ||
| "structural_compliance": f0valm, | ||
| "thermal_compliance": f0valt, | ||
| "volume_fraction": vf_error, | ||
| "volume_fraction_error": vf_error, | ||
| } | ||
|
Comment on lines
285
to
289
|
||
| vf_error = np.abs(np.mean(x) - volfrac) | ||
| obj_values = np.array([f0valm, f0valt, vf_error]) | ||
|
|
@@ -353,7 +353,7 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str | |
| "bcs": bcs, | ||
| "structural_compliance": f0valm, | ||
| "thermal_compliance": f0valt, | ||
| "volume_fraction": vf_error, | ||
| "volume_fraction_error": vf_error, | ||
| "opti_steps": opti_steps, | ||
| } | ||
|
|
||
|
|
@@ -372,7 +372,7 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str | |
| "fixed_elements": [lci[21], lci[32], lci[43]], | ||
| "force_elements_y": [bri[31]], | ||
| "heatsink_elements": [lci[31], lci[32], lci[33]], | ||
| "volfrac": 0.2, | ||
| "volume_fraction_target": 0.2, | ||
| "rmin": 1.1, | ||
| "weight": 1.0, # 1.0 for pure structural, 0.0 for pure thermal | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ class ThermoElastic2D(Problem[npt.NDArray]): | |
| objectives: tuple[tuple[str, ObjectiveDirection], ...] = ( | ||
| ("structural_compliance", ObjectiveDirection.MINIMIZE), | ||
| ("thermal_compliance", ObjectiveDirection.MINIMIZE), | ||
| ("volume_fraction", ObjectiveDirection.MINIMIZE), | ||
| ("volume_fraction_error", ObjectiveDirection.MINIMIZE), | ||
| ) | ||
|
|
||
| @dataclass | ||
|
|
@@ -65,7 +65,7 @@ class Conditions: | |
| default_factory=lambda: HEATSINK_ELEMENTS | ||
| ) | ||
| """Binary NxN matrix specifying elements that have a heat sink""" | ||
| volfrac: Annotated[float, bounded(lower=0.0, upper=1.0).category(THEORY)] = 0.3 | ||
| volume_fraction_target: Annotated[float, bounded(lower=0.0, upper=1.0).category(THEORY)] = 0.3 | ||
|
||
| """Target volume fraction for the volume fraction constraint""" | ||
| rmin: Annotated[ | ||
| float, bounded(lower=1.0).category(THEORY), bounded(lower=0.0, upper=3.0).warning().category(IMPL) | ||
|
|
@@ -129,7 +129,7 @@ def simulate(self, design: npt.NDArray, config: dict[str, Any] | None = None) -> | |
| boundary_dict[key] = value | ||
|
|
||
| results = FeaModel(plot=False, eval_only=True).run(boundary_dict, x_init=design) | ||
| return np.array([results["structural_compliance"], results["thermal_compliance"], results["volume_fraction"]]) | ||
| return np.array([results["structural_compliance"], results["thermal_compliance"], results["volume_fraction_error"]]) | ||
|
Comment on lines
131
to
+132
|
||
|
|
||
| def optimize( | ||
| self, starting_point: npt.NDArray, config: dict[str, Any] | None = 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.
The docstring was updated to list
volume_fraction_target, but the rest of theReturns:section still refers to keys like'sc','tc', and'vf'. Please update the return-key documentation to match the actual dict keys returned (e.g.,structural_compliance,thermal_compliance,volume_fraction_error).