From 4079a39bae71bc1765b433e1337713f90e8c3ebc Mon Sep 17 00:00:00 2001 From: Arjun Rao Date: Thu, 15 Oct 2026 22:10:31 -0500 Subject: [PATCH] Send FourPost bar rates only to the rig bars that exist FourPost sent each bar rate twice, to pFrStabar.barRate and to pVehicle.pFrStabar.barRate. The rig binds only pFrStabar. The executable logs the pVehicle override as applied, but it changes no output: a run without it gives bit-identical results. It also sent a rate of 0 for an axle with no bar, where the template value is already 0. Now FourPost sends the rig bar rate only, and only for an axle that has a bar in the vehicle file. --- .../mbd/four_post/four_post_eval_sim.py | 9 ++++----- tests/test_kinematics.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/simulations/response/mbd/four_post/four_post_eval_sim.py b/simulations/response/mbd/four_post/four_post_eval_sim.py index 73862685..c070e5a8 100644 --- a/simulations/response/mbd/four_post/four_post_eval_sim.py +++ b/simulations/response/mbd/four_post/four_post_eval_sim.py @@ -906,12 +906,11 @@ def build_model_setup_overrides(self) -> dict[str, float]: overrides: dict[str, float] = { "pVehicle.pFrAxleDW.springFreeLength": float(setup["front_spring_free_length"]), "pVehicle.pRrAxleDW.springFreeLength": float(setup["rear_spring_free_length"]), - "pVehicle.pFrStabar.barRate": front_stabar_rate, - "pVehicle.pRrStabar.barRate": rear_stabar_rate, - # Templates zero the bars for pure K&C. Set them for the load-transfer pass. - "pFrStabar.barRate": front_stabar_rate, - "pRrStabar.barRate": rear_stabar_rate, } + # The rig binds p{Fr,Rr}Stabar, not pVehicle.p{Fr,Rr}Stabar. Its templates zero the bars for pure K&C. + for tag, axle_name, bar_rate in (("Fr", "front", front_stabar_rate), ("Rr", "rear", rear_stabar_rate)): + if _side_has_stabar(setup[f"{axle_name}_side"]): + overrides[f"p{tag}Stabar.barRate"] = bar_rate overrides.update( _indexed_table_overrides( "pVehicle.pFrAxleDW.springTable", diff --git a/tests/test_kinematics.py b/tests/test_kinematics.py index 8b4b9476..afdc8a29 100644 --- a/tests/test_kinematics.py +++ b/tests/test_kinematics.py @@ -1146,3 +1146,20 @@ def test_four_post_preserves_vehicle_spring_curves_without_rate_overrides( }) np.testing.assert_array_equal(overridden["front_spring_table"][:, 1], np.asarray(tables["front"])[:, 0] * 10000.0) np.testing.assert_array_equal(overridden["rear_spring_table"], tables["rear"]) + + +def test_four_post_sends_bar_rates_only_to_the_rig_bars_that_exist( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + vehicle = _four_post_unit_vehicle() + front = vehicle["front"] + assert isinstance(front, dict) + front["actuation"].pop("stabar") + monkeypatch.setattr(four_post_eval, "_load_active_vehicle_yaml", lambda: vehicle) + + overrides = four_post_eval.FourPostEvalSim(_four_post_unit_config(tmp_path)).build_model_setup_overrides() + + assert not [key for key in overrides if key.startswith("pVehicle.") and "Stabar" in key] + assert "pFrStabar.barRate" not in overrides + assert overrides["pRrStabar.barRate"] == 0.0