The 'ModelChain' Endpoint Tutorial
Note
This tutorial assumes you have already set up a Python environment on your machine. If not, see Setting up a Python Environment for help on how to set this up.
Definition
See the ModelChain Endpoint for a definition of this endpoint.
Tutorial
We have provided some files for the tutorial. These were generated from the SolarFarmer desktop application for a simple fixed-tilt racks site which looks like this:
It is a fictitious fixed-tilt rack site. 3 inverters. Racks are 30 modules long, 3 module high. String length is 30.
- Create a new empty folder (e.g. in
C:\Temp\Tutorials
) - Open the following link in a new tab: ModelChainEndpointTutorial.py
- Select all the text and copy it to the clipboard.
- Create an empty text file in your new empty folder and paste the script text into your empty text file and save
it as a Python file (e.g. as
"ModelChainEndpointTutorial.py"
). - Replace the text 'ENTER YOUR API KEY HERE!!!' with your personal API key (encase it in single quotes)
- Download the following file: Inputs.zip
- Unzip it into your folder. So you should have an
Inputs
sub-folder. This contains the input files needed to run the ModelChain endpoint for this tutorial. - The
EnergyCalculationInputs
object required was saved to the"EnergyCalcInputs.json"
file for this tutorial rather than created manually in python. Open it in a text editor to examine its contents.
- Unzip it into your folder. So you should have an
- Open a command prompt in the folder
- Type
python ModelChainEndpointTutorial.py
and hit Return to run the script. - It may take around 10 seconds to run, and you should see output similar to this:
Sending POST request to https://solarfarmer.dnvgl.com/api/ModelChain...
Request has returned...
SUCCESS: Calculation returned successfully
Energy yield results totals for year:
{
"recordCount": 8841,
"percentComplete": 99.99999999999983,
"averageTemperature": 10.607920426907318,
"ghi": 1192.7340000000002,
"gi": 1373.3998258765307,
"giWithHorizon": 1373.3998258765307,
"gainOnTiltedPlane": 0.15147201796589216,
"globalEffectiveIrradiance": 1297.7553867887952,
"modulePower": 556172.6053148757,
"modulePowerAtSTC": 578228.7683861437,
"nominalEnergy": 578150.0248144084,
"pdc": 535546.0403715704,
"pac": 519250.67326979205,
"performanceRatio": 0.821871171201173,
"netEnergy": 502.8615657838914,
"energyYield": 1128.7577234206315
}
Saved annual energy yield results to C:\Temp\Tutorials\Outputs\AnnualEnergyResults.json
Sum EOutInv column in PVsyst format results to get total AC annual energy: 519250.840913 kWh
Saved PVsyst results file to C:\Temp\Tutorials\Outputs\PVsystResults.csv
Saved timeseries results file to C:\Temp\Tutorials\Outputs\TimeSeriesResults.tsv
Saved loss tree results file to C:\Temp\Tutorials\Outputs\LossTreeResults.tsv
There should be an Outputs
folder now in your folder. This will contain 4 files containing the results
extracted from the ModelChainResponse
object returned.
See the Outputs section in ModelChain Endpoint for more detailed information on these outputs.
A quick summary:
AnnualEnergyResults.json
- this is the annual energy results for the yearPVsystResults.csv
- the PVsyst results file.- To view in Excel:
- Create a new Excel workbook
- Go to the Data ribbon and click the 'From Text/CSV' button
- Select the
PVsystResults.csv
file that was written and click 'Import' - It should automatically detect that the Semicolon is the delimiter.
- Click 'Load' to load it
- To view in Excel:
TimeSeriesResults.tsv
- time series results file (tab separated data).LossTreeResults.tsv
- loss tree results (tab separated data).
If you have this up and running then you can successfully run a simple energy calculation! Well done.
The next step for you will be to start constructing your own inputs and analyzing the output results for yourself. Good luck!