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_scales_as_current_squared(): # F = 0.5*I^2*dL/dx: без клэмпа (см. модуль-докстринг force.py про энергобаланс) # сила должна расти строго как I^2, иначе нарушится точный энергобаланс контура. f_low = force_on_slug_newtons(current_a=5, dl_dx=1e-3) f_high = force_on_slug_newtons(current_a=50, dl_dx=1e-3) assert f_high / f_low == pytest.approx(100.0) def test_force_zero_at_zero_current(): assert force_on_slug_newtons(current_a=0, dl_dx=1e-3) == pytest.approx(0.0)