Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solarfarmer/models/pvsystem/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_construct_plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from solarfarmer.models.pvsystem.pvsystem import (
construct_plant,
design_plant,
generate_mounting_specs,
generate_pan_file_supplements,
)

Expand Down Expand Up @@ -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]."""

Expand Down
Loading