Fix FIRE integrator momentum, convergence, and backward-compatibility issues#27
Draft
Copilot wants to merge 3 commits into5-fix-issue-with-geometry-breaking-from-time-to-timefrom
Draft
Conversation
Co-authored-by: Pablo1990 <1974224+Pablo1990@users.noreply.github.com>
…aults, use hasattr() instead of getattr() Co-authored-by: Pablo1990 <1974224+Pablo1990@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with geometry breaking from time to time
Fix FIRE integrator momentum, convergence, and backward-compatibility issues
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses several correctness bugs in the FIRE minimizer and related infrastructure that caused geometry instability, broken momentum, and test failures when loading older
.pklmodel states.Core FIRE algorithm fixes (
integrators.py)single_iteration_fireunconditionally resetgeo._fire_velocity = np.zeros(...)after thehasattrguard, nullifying the guard's intent. Removed the reset;fire_minimization_loopnow owns initialization viainitialize_fire()..flatten()returns a copy — writes tovelocity.flatten()[dof]never persisted. Replaced with.reshape(-1)(view) so assignments write through togeo._fire_velocity.check_if_fire_convergedreturnedconverged=Truewheniteration_count >= max_iter. Changed toFalse; stalling is not convergence.newton_raphsonreturns 8 values; the remodelling call unpacked 9.Non-convergence handling (
vertexModel.py)FIRE non-convergence fell through silently with just a
logger.warning. Now callsiteration_did_not_converged(), which restores backup geometry and setsdidNotConverge = True, matching the Euler branch behavior.Backward compatibility (
set.py)Added
__setstate__using a_BACKWARD_COMPAT_DEFAULTSclass constant so older pickledSetinstances gain missing FIRE/integrator attributes on load withoutAttributeError.Other correctness fixes
__init__.py: StreamHandler guard was matchingFileHandler(a subclass) — now checkshandler.stream in (sys.stdout, sys.stderr).analyse_simulation.py: Removed unconditionalintegrator = 'euler'override that discarded the model's saved integrator.find_required_purse_string.py: Sortdirs_withinbefore selecting index 0 (deterministic); usehasattr()instead of falsygetattrto guard integrator/tolerance overrides.geo.py: Addednp.isfinite()guards forVol,Area, andtri.Areain geometry validation; renamed loop variablescell→c_cell,face→c_faceto eliminate module shadowing.utils.py:y_axis_labelcheck uses substring match instead of exact string to handle dynamic labels like"Purse string strength (t=6.0)".Test infrastructure
tests.py:load_datauses absoluteos.path.join(TEST_DIRECTORY, 'Tests_data', ...)path; returns consistent(None, None, v_model)tuple for.pklfiles; normalizesOutputFolderforNone,b'', and''.test_vertexModel.py: FixednewtonRaphson.KgGlobal→integrators.KgGlobal; corrected fixture path; aligned "10 iterations" comments with actual20 * dt0window.load_data('.pkl')callers updated to unpack_, _, vModel = load_data(...).💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.