diff --git a/solarfarmer/models/pvsystem/pvsystem.py b/solarfarmer/models/pvsystem/pvsystem.py index c440480..2247e5c 100644 --- a/solarfarmer/models/pvsystem/pvsystem.py +++ b/solarfarmer/models/pvsystem/pvsystem.py @@ -1778,7 +1778,7 @@ def generate_mounting_specs( # the orientation is set to the plane in the layout if plant.flush_mount: height_from_ground = 0.1 # A small height of 10 cm - tilt_angle = 0.0 + tilt_angle = plant.tilt else: height_from_ground = plant.mounting_height tilt_angle = plant.tilt if plant.tilt is not None else round(plant.latitude) diff --git a/tests/test_construct_plant.py b/tests/test_construct_plant.py index 40bae29..f8aaf65 100644 --- a/tests/test_construct_plant.py +++ b/tests/test_construct_plant.py @@ -7,6 +7,7 @@ from solarfarmer.models.pvsystem.pvsystem import ( construct_plant, design_plant, + generate_mounting_specs, generate_pan_file_supplements, ) @@ -122,6 +123,32 @@ def total_inverters(pv_plant): assert total_inverters(small_plant) < total_inverters(large_plant) +class TestGenerateMountingSpecs: + """Regression tests for generate_mounting_specs().""" + + def test_flush_mount_uses_plant_tilt(self): + """Flush-mount fixed systems should preserve plant.tilt in mounting specs.""" + plant = PVSystem( + latitude=46.95, + longitude=7.44, + mounting="Fixed", + flush_mount=True, + tilt=15.0, + ) + + specs = generate_mounting_specs( + mounting_type_id="Mounting Type 1", + plant=plant, + are_modules_landscape=False, + rack_height=2.0, + y_spacing=0.02, + ) + + spec = specs["Mounting Type 1"] + assert spec.tilt == pytest.approx(15.0) + assert spec.height_of_lowest_edge_from_ground == pytest.approx(0.1) + + class TestSpecIdDerivation: """Verify spec IDs are derived via Path.stem (last-dot split), not split('.')[0]."""