Skip to content

fix(thermoelastic2d): align column names with v1 dataset#247

Open
mkeeler43 wants to merge 1 commit intomainfrom
fix/thermoelastic2d-v1-column-names
Open

fix(thermoelastic2d): align column names with v1 dataset#247
mkeeler43 wants to merge 1 commit intomainfrom
fix/thermoelastic2d-v1-column-names

Conversation

@mkeeler43
Copy link
Copy Markdown
Contributor

Summary

  • Rename volfracvolume_fraction_target in Conditions dataclass and fea_model.py to match the v1 HuggingFace dataset column name
  • Rename volume_fractionvolume_fraction_error in objectives tuple and all fea_model.py return dicts to match the v1 dataset

Test plan

  • Verified conditions_keys all exist in thermoelastic_2d_v1 dataset columns
  • Verified objectives names all exist in thermoelastic_2d_v1 dataset columns
  • Ran simulate() successfully on a random design from the dataset
  • Ran optimize() successfully with max_iter=5

🤖 Generated with Claude Code

Rename `volfrac` → `volume_fraction_target` in Conditions and fea_model,
and `volume_fraction` → `volume_fraction_error` in objectives and return dicts
to match the thermoelastic_2d_v1 HuggingFace dataset schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns thermoelastic2d v0 problem input/output field names with the v1 HuggingFace dataset schema, so dataset-driven configs and objective columns match simulator/optimizer expectations.

Changes:

  • Renamed condition key volfracvolume_fraction_target in ThermoElastic2D.Conditions and FeaModel.run() boundary-condition parsing.
  • Renamed objective/result key volume_fractionvolume_fraction_error across objectives and returned result dicts.
  • Updated the 2D FEA model’s example bcs to use the new key name.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
engibench/problems/thermoelastic2d/v0.py Updates objective name and condition field to match v1 dataset columns; updates simulate() to read the renamed result key.
engibench/problems/thermoelastic2d/model/fea_model.py Updates expected BC key and returned result dict key to match v1 dataset columns; updates local __main__ example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 131 to +132
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"]])
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This method returns an np.ndarray (objective values), but the docstring currently describes returning a dict of named objective values. Please update the docstring/return description to match the actual return type and clarify the ordering of objectives in the returned array.

Copilot uses AI. Check for mistakes.
)
"""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
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Renaming volfrac to volume_fraction_target is a breaking change for any callers passing configs with the old key. To avoid silent misconfiguration (the config merge only updates known keys), consider accepting volfrac as a deprecated alias (mapping it to volume_fraction_target) and/or raising a clear error when volfrac is provided.

Copilot uses AI. Check for mistakes.
Comment on lines 147 to 150
nely = fe_w - 1

volfrac = bcs["volfrac"]
volfrac = bcs["volume_fraction_target"]
n = nely * nelx # Total number of elements
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

run() now requires bcs["volume_fraction_target"], which will raise KeyError for existing callers still providing volfrac. Consider supporting volfrac as a deprecated fallback (or at least raising a clearer ValueError with the expected key names) to make this migration less error-prone.

Copilot uses AI. Check for mistakes.
Comment on lines 119 to 123
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.
Copy link

Copilot AI Apr 9, 2026

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 the Returns: 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).

Copilot uses AI. Check for mistakes.
Comment on lines 285 to 289
return {
"structural_compliance": f0valm,
"thermal_compliance": f0valt,
"volume_fraction": vf_error,
"volume_fraction_error": vf_error,
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Renaming the returned key from volume_fraction to volume_fraction_error is a breaking change for any downstream consumers of FeaModel.run() results. If you need backwards compatibility, consider returning both keys for a deprecation window (or documenting this change prominently).

Copilot uses AI. Check for mistakes.
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.

2 participants