Repository navigation
Document rack corner order and warn when a rack faces below the horizon - #59
Conversation
The order of a rack's quad corners decides which face the calculation treats as the front of the modules, but QuadDouble and Rack did not document it, and every rack fixture in test_composition.py used the reverse order. That order passes validation and completes, but in an unshaded 3D control it returned about 15% of the equivalent 2D energy. - Document the order on QuadDouble and Rack: P1 at the low corner, P1->P2 up the slope, P1->P4 along the row (SW-low, NW-high, NE-high, SE-low for a south-facing rack), with x east, y north and z up, matching the ModelChainAsync documentation example - Add QuadDouble.width, depth, front_normal, tilt and azimuth - Issue RackOrientationWarning when a rack's front face points below the horizon, or its quad has no area - Correct the four rack fixtures in test_composition.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A validator on every Rack added about 7 us per rack and printed one warning per reversed rack: 130,000 warnings for a 500 MW layout of 7-module racks generated in the wrong order. PVPlant and Racks now check all of their racks in one pass and issue a single RackOrientationWarning with the count and the first ten rack IDs. Validating 130,000 racks takes the same time as without the check (0.74 s here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
focused 2D/3D parity tests belong in this PR. They directly address the silent energy failure, and they’re already part of #58’s acceptance check. Use Bern as the resource, not the whole plant I’d include: A single-orientation, unshaded case. The multi-module documentation gap also belongs here Rack-local X increases P1→P4; Y increases P1→P2. |
Review on dnv-opensource#59 asked for the 2D/3D parity check from dnv-opensource#58's acceptance criteria and for the multi-module documentation the PR left out. - QuadDouble and ModuleIndexRange document where modules sit on a rack: index x counts along the row from the P1 end, y counts rows up the slope from the P1-P4 edge, and frame widths and spacing set each module's position. A descending range covers the same modules. The docs note that the SDK does not check the quad's size against the mounting type. - tests/test_rack_3d_parity.py (integration, skipped without SF_API_KEY) builds small plants from the Bern sample's weather, PAN and OND files: two-row south-facing racks and mixed-orientation racks must match the equivalent 2D layout within 0.1% with no near shading, and a wall in front of one end must show that index 0 is the module at P1. Results on API 7.0.15: the largest 2D/3D difference was 0.00076%, and the string at the P1 end behind the wall produced 1/9 of the same string at the other end. Every single-rack 3D plant we tried ended with status Failed and no reason, so each test plant has two racks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Both are in ea3a6ce, with two changes to the plan. Parity tests: Module positions: I left out the offline indexing test. The SDK passes Single-rack plants fail silently. Every 3D plant I tried with only one rack ended with 🤖 Generated with Claude Code |
wholmgren-dnv
left a comment
There was a problem hiding this comment.
Reviewed ea3a6ce. The Bern-based parity cases and multi-module diagram address the earlier feedback well. The live wall test is better evidence than the proposed serialization-only indexing test; I agree with leaving that offline test out.
Two remaining findings are attached inline. Before declaring live validation complete, please rerun the mixed-orientation case on the exact committed version: the description says it was not rerun after corner rounding.
Two smaller documentation points:
- The collection check can issue two warnings when both reversed and degenerate racks are present, rather than the advertised single warning. Either qualify the wording or combine the messages.
- Please link the ModelChainAsync documentation, Racks and Trackers section in the PR description and beside the example-based geometry test. Its example matches this PR, but its unqualified anti-clockwise wording is misleading. The convention is confirmed by inspection of SF-Core; the public documentation wording should be corrected separately.
Validation: 78 focused tests passed, 3 live tests skipped; targeted Ruff lint and formatting passed. All six payload-construction paths were exercised offline. No live API calculations were submitted during this review.
| a row on the mount. On a rack, index 0 is the module at the ``P1`` | ||
| end; see :class:`~solarfarmer.models.QuadDouble`. May be larger than | ||
| ``end_x``: the range then covers the same modules, wired in the | ||
| opposite direction along the row |
There was a problem hiding this comment.
[P2] Please remove the guarantee that descending endpoints mean modules are wired in the opposite direction. The reliable guarantee here is that they select the same inclusive module positions; reversed electrical traversal is not established by the new tests. This qualification is confirmed by inspection of SF-Core. Suggested wording: 'May be larger than end_x; either endpoint order covers the same inclusive module positions.'
| assert result_3d["effective_irradiation"] == pytest.approx( | ||
| result_2d["effective_irradiation"], rel=ENERGY_TOLERANCE | ||
| ) | ||
| assert result_3d["net_energy"] == pytest.approx(result_2d["net_energy"], rel=ENERGY_TOLERANCE) |
There was a problem hiding this comment.
[P2] These parity assertions accept two zero-production summaries. I reproduced _assert_parity({'effective_irradiation': 0.0, 'net_energy': 0.0, 'near_shading': 0.0}, same_summary) passing. The wall test can also accept certain negative-energy comparisons. Please assert finite, positive effective irradiation and net energy in the shared _annual helper before returning its summary, so all three tests reject invalid/non-producing results before their relative comparisons.
There was a problem hiding this comment.
Done in 1b74cb8. _annual now asserts finite, positive effective irradiation and net energy (and finite near shading) before returning, so all three tests reject non-producing results. I checked it offline with zero, negative and NaN summaries.
- Reversed and zero-area racks now share a single RackOrientationWarning instead of one each, matching the documented "one warning". - ModuleIndexRange no longer claims that a descending range is wired in the opposite direction; either endpoint order covers the same inclusive module positions. - The live tests' _annual helper rejects non-finite or non-positive effective irradiation and net energy, so two zero-production results can no longer pass the relative comparisons. - The documentation-example geometry test links the ModelChainAsync "Racks and Trackers" section and notes that its "anti-clockwise" wording holds only when seen from below. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The mixed-orientation case passes on 1b74cb8 with the same results as before. Reversed and zero-area racks now share one warning, with a test for both together. The Racks and Trackers link is in the description and in the example test's docstring. |
The racks were 200 m apart, which made the scenes mostly empty ground. Two-row racks and the indexing test's spare rack now stand in one row 20 m apart (RACK_GAP), and the mixed-orientation racks' nearest corners are 40 m apart. A neighbour can then shade a rack only with the sun within about 6 degrees of the horizon in the east or west. Rerun on API 7.0.15: the two-row and indexing results are unchanged to the printed precision; the mixed-orientation 3D/2D energy difference went from 0.00076% to 0.0034%, and its near shading from 0.000003 to 0.00003, well inside the 0.1% and 0.001 tolerances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
javlor
left a comment
There was a problem hiding this comment.
Thank you for the contribution Will.
Closes #58
What this changes
QuadDoubleandRacknow document the corner order (P1 at the low corner, P1→P2 up the slope, P1→P4 along the row: SW-low, NW-high, NE-high, SE-low for a south-facing rack) and the axes (x east, y north, z up). This matches the example rack in the ModelChainAsync documentation's Racks and Trackers section. That page calls the order "anti-clockwise around the rack", which holds only when seen from below; from above or from the front of the modules it is clockwise. Review confirmed the convention against SF-Core; the documentation's wording should be corrected separately.QuadDoubleandModuleIndexRangedocument where modules sit on a rack, with a 3 × 2 diagram. Indexxcounts along the row from the P1 end, andycounts rows up the slope from the P1–P4 edge. Module (0, 0) is inset from P1 byframe_end_widthandframe_bottom_width, and the module spacing sets the rest. Either endpoint order covers the same inclusive module positions. The docs also say the SDK doesn't check the quad's size against the mounting type, so correct winding alone doesn't mean the modules fit.QuadDouble.width,depth,front_normal,tiltandazimuthshow how a quad's corners will be read.PVPlantandRacksissue oneRackOrientationWarning(exported fromsolarfarmer) when any racks' front faces point below the horizon or their quads have no area. A single warning covers both cases, with the count and the first ten rack IDs for each. It warns rather than reordering corners, because reordering would also change module indexing.tests/test_models/test_composition.pyused the reverse order and are corrected.tests/test_rack_3d_parity.py, markedintegrationand skipped withoutSF_API_KEY. They build small plants from the Bern sample's weather, PAN and OND files, with identical equipment, electrical layout and losses in 2D and 3D.Why the orientation check runs on the collection, not on
RackA validator on every
Rackadded about 7 µs per rack and printed one warning per reversed rack. A 500 MW layout of 7-module racks (about 130,000 racks) generated in the wrong order would print 130,000 warnings. The collection-level check validates 130,000 racks in the same time as without it (0.74 s locally) and issues one warning. A standaloneRackisn't checked until it goes into aPVPlantorRacks.Live test results (API 7.0.15)
Near shading was 0 and −0.00003. The tests allow 0.1% and 0.001; a reversed rack is off by about 85%. At those spacings a neighbour can shade a rack only with the sun within about 6° of the horizon. With the racks 200 m apart, the mixed-orientation differences were −0.0002% and −0.00076%, and near shading was −0.000003.
Energy parity can't catch an indexing error, because every module on an unshaded rack sees the same irradiance. So
test_module_index_x_starts_at_p1puts a wall in front of the P1 (west) end of a 48-module rack. It wires 30 modules as a live string and the other 18 to an inverter they can't reach the MPPT window of, so the plant's energy is the live string's. The live string produced 0.605 MWh starting at index 0 and 5.523 MWh starting at index 18 (unchanged by moving the spare rack from 200 m to 20 m away), so index 0 is at P1.The
ydirection, frame insets and spacing follow the definitions in the web API reference. The tests use zero frames and one-row strings, so they don't exercise those beyondy= 0 and 1.Notes for the service team
runtimeStatus"Failed" and nullcustomStatusandoutput, after 6–12 s. That covered four wirings, with and without a shading object, and the full status payload gave no reason. The same racks completed in two-rack plants, so each test plant has two.Testing
TestQuadDoubleGeometry(6 tests, including the documentation's example rack: tilt 34.0°, azimuth 177.4°) andTestRackOrientation(8 tests) intests/test_models/test_validation.py.RackOrientationWarningtreated as an error.ruff checkandruff format --checkpass (ruff 0.14.14, as pinned in pre-commit).tests/test_rack_3d_parity.pypass withSF_API_KEYset. All three were rerun on f63ff5a, which moved the racks closer together. The shared helper rejects non-finite or non-positive effective irradiation and net energy, so two zero-production results can't pass a relative comparison.🤖 Generated with Claude Code