import pytest from gausse.physics.force import ( force_on_slug_newtons, saturation_scale, solenoid_field_estimate_tesla, ) def test_field_estimate_scales_with_current_and_turns(): b_low = solenoid_field_estimate_tesla(mu_eff=100, total_turns=100, coil_length_m=0.05, current_a=10) b_high = solenoid_field_estimate_tesla(mu_eff=100, total_turns=100, coil_length_m=0.05, current_a=100) assert b_high > b_low def test_saturation_scale_is_one_below_bsat(): assert saturation_scale(b_estimate_tesla=0.5, b_sat_tesla=1.8) == pytest.approx(1.0) def test_saturation_scale_clamps_above_bsat(): scale = saturation_scale(b_estimate_tesla=3.6, b_sat_tesla=1.8) assert scale == pytest.approx(0.5) def test_force_is_reduced_once_saturated(): common = dict(dl_dx_unsaturated=1e-3, mu_eff=200, total_turns=300, coil_length_m=0.05, b_sat_tesla=1.8) force_unsaturated = force_on_slug_newtons(current_a=5, **common) force_saturated = force_on_slug_newtons(current_a=500, **common) # без клэмпа сила росла бы как I^2 (в 10000 раз); с насыщением рост должен быть намного меньше assert force_saturated / force_unsaturated < 5000 def test_force_zero_at_zero_current(): common = dict(dl_dx_unsaturated=1e-3, mu_eff=200, total_turns=300, coil_length_m=0.05, b_sat_tesla=1.8) assert force_on_slug_newtons(current_a=0, **common) == pytest.approx(0.0)