Skip to content

Commit

Permalink
Pysam v5 (#160)
Browse files Browse the repository at this point in the history
* update files

* fix AdjustmentFactors

* update files

* update tests and examples

* update tests and docs

* fix tcsmslf

* fix name

* fix build files

* consolidate unix build files

* Update docs
  • Loading branch information
dguittet authored Dec 20, 2023
1 parent 5043265 commit bb95eab
Show file tree
Hide file tree
Showing 239 changed files with 69,987 additions and 11,299 deletions.
3 changes: 1 addition & 2 deletions Examples/100kW_PVWatts.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Examples/BatteryStateful.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Examples/BatteryWithCustomDispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Additional financial models, inputs, and outputs can be found at https://nrel-pysam.readthedocs.io/en/master/modules/Battery.html
Most recently tested against PySAM 4.2.0
Most recently tested against PySAM 5.0.0
@author: brtietz
"""
Expand Down
2 changes: 1 addition & 1 deletion Examples/FetchResourceFileExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
To use the `FetchResourceFile` function, register an email address to receive a
free API key at at https://developer.nrel.gov/signup/.
Most recently tested against PySAM 4.2.0
Most recently tested against PySAM 5.0.0
@authors: skoeb, cpaulgilman
'''
Expand Down
2 changes: 1 addition & 1 deletion Examples/GenericSystemSingleOwnerExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Created on Wed Mar 4 13:47:58 2020
Most recently tested against PySAM 4.2.0
Most recently tested against PySAM 5.0.0
@author: frohro
"""
Expand Down
1 change: 1 addition & 0 deletions Examples/LoadToolsExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
A usage example for LoadTools.get_monthly peaks with hourly annual data
Requires PySAM 4.2.0 or greater
Recently tested with 5.0.0
"""
if __name__ == "__main__":
df = pd.read_csv(str(Path(__file__).parent / "sample_load.csv"), dtype=float)
Expand Down
4 changes: 2 additions & 2 deletions Examples/Marine energy examples/WaveFileReader_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"4.2.0\n"
"5.0.0\n"
]
}
],
Expand Down Expand Up @@ -162,7 +162,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.8.17"
},
"vscode": {
"interpreter": {
Expand Down
13 changes: 9 additions & 4 deletions Examples/NonAnnualSimulation.ipynb

Large diffs are not rendered by default.

45 changes: 34 additions & 11 deletions Examples/PySAMWorkshop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"\n",
"https://sam.nrel.gov/software-development-kit-sdk/pysam.html\n",
"\n",
"Edit: Most recently tested with Version 4.2.0"
"Edit: Most recently tested with Version 5.0.0"
]
},
{
Expand Down Expand Up @@ -97,6 +97,7 @@
"{'SolarResource': {},\n",
" 'Lifetime': {},\n",
" 'SystemDesign': {},\n",
" 'Shading': {},\n",
" 'AdjustmentFactors': {},\n",
" 'Outputs': {}}"
]
Expand Down Expand Up @@ -144,6 +145,10 @@
" \n",
" - *\"FuelCellSingleOwner\"*\n",
" \n",
" - *\"GenericPVWattsWindFuelCellBatteryHybridHostDeveloper\"*\n",
" \n",
" - *\"GenericPVWattsWindFuelCellBatteryHybridSingleOwner\"*\n",
" \n",
" - *\"PVWattsBatteryCommercial\"*\n",
" \n",
" - *\"PVWattsBatteryHostDeveloper\"*\n",
Expand All @@ -152,6 +157,14 @@
" \n",
" - *\"PVWattsBatteryThirdParty\"*\n",
" \n",
" - *\"PVWattsWindBatteryHybridHostDeveloper\"*\n",
" \n",
" - *\"PVWattsWindBatteryHybridSingleOwner\"*\n",
" \n",
" - *\"PVWattsWindFuelCellBatteryHybridHostDeveloper\"*\n",
" \n",
" - *\"PVWattsWindFuelCellBatteryHybridSingleOwner\"*\n",
" \n",
" - *\"PVWattsAllEquityPartnershipFlip\"*\n",
" \n",
" - *\"PVWattsCommercial\"*\n",
Expand Down Expand Up @@ -225,7 +238,17 @@
" 'soiling': (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),\n",
" 'system_capacity': 215.0,\n",
" 'tilt': 20.0},\n",
" 'AdjustmentFactors': {'constant': 0.0},\n",
" 'Shading': {'shading_azal': ((0.0,),),\n",
" 'shading_diff': 0.0,\n",
" 'shading_en_azal': 0.0,\n",
" 'shading_en_diff': 0.0,\n",
" 'shading_en_mxh': 0.0,\n",
" 'shading_en_string_option': 0.0,\n",
" 'shading_en_timestep': 0.0,\n",
" 'shading_mxh': ((0.0,),),\n",
" 'shading_string_option': 0.0,\n",
" 'shading_timestep': ((0.0,),)},\n",
" 'AdjustmentFactors': {},\n",
" 'Outputs': {}}"
]
},
Expand Down Expand Up @@ -355,24 +378,24 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"gen\n",
" (0.0, 0.0, 0.0, 0.0, 0.0, -0.0, 6.389046797900428, 37.94398351785478, 67.06449907636099, 92.89776429848214)\n",
" (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 15.957267664043416, 46.359814033282966, 79.21016610727209)\n",
"\n",
"annual energy value\n",
" (0.0, 19406.19405690556, 19800.52382533316, 20202.441481670056, 20612.079886380227, 21029.57424662404, 21455.061069906493, 21888.678750448922, 22330.56790184979, 22780.871493923893, 23239.73432549519, 23707.302537008924, 24183.724540467367, 24669.151054164817, 25162.80184412058, 25665.45272176825, 26177.509583152998, 26699.128805377077, 27230.468045222864, 27771.6872915576, 28322.60044366972)\n"
" (0.0, 31185.166327531133, 31826.471693815998, 32480.351606056192, 33147.03432502806, 33826.75096019472, 34519.73674809185, 35226.23060963128, 35946.40851883473, 36679.799902242536, 37427.394937218596, 38189.44523102771, 38966.20651701934, 39757.93772713312, 40564.90191657865, 41387.365633383946, 42225.59961194162, 43079.05838829027, 43948.38185076402, 44834.2470796484, 45736.93783132027)\n"
]
}
],
"source": [
"# execute PV then utility rate calculations\n",
"default_model.SolarResource.solar_resource_file = \"/Users/dguittet/SAM Downloaded Weather Files/weather.csv\"\n",
"default_model.SolarResource.solar_resource_file = \"../tests/blythe_ca_33.617773_-114.588261_nasa_60_tmy.csv\"\n",
"default_model.execute(0)\n",
"print('gen\\n', default_model.Outputs.gen[0:10])\n",
"\n",
Expand All @@ -394,7 +417,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -433,7 +456,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -456,7 +479,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -496,7 +519,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -561,7 +584,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.8.17"
},
"vscode": {
"interpreter": {
Expand Down
8 changes: 6 additions & 2 deletions Examples/ResidentialPVBatteryWithCustomDispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
* PV: https://nrel-pysam.readthedocs.io/en/master/modules/Pvsamv1.html
* Battery: https://nrel-pysam.readthedocs.io/en/master/modules/Battery.html
Most recently tested against PySAM 4.2.0
Most recently tested against PySAM 5.0.0
@author: brtietz
"""

import PySAM.Battery as battery_model
import PySAM.Pvsamv1 as pvsam
from PySAM.PySSC import *
from pathlib import Path

weather_file = sys.argv[1] # .csv weather file with tmy format
if len(sys.argv) > 1:
weather_file = sys.argv[1] # .csv weather file with tmy format
else:
weather_file = str(Path(__file__).parent.parent / "tests" / "blythe_ca_33.617773_-114.588261_nasa_60_tmy.csv")

analysis_period = 1 # years
days_in_year = 365
Expand Down
6 changes: 5 additions & 1 deletion Examples/SAMsimPVWattsCommercialExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
Run the simulations.
Print the results.
Most recently tested against PySAM 4.2.0
Most recently tested against PySAM 5.0.0
@author: frohro
"""

import json
from pathlib import Path
import PySAM.Pvwattsv8 as PVWatts
import PySAM.Grid as Grid
import PySAM.Utilityrate5 as UtilityRate
Expand Down Expand Up @@ -54,6 +55,9 @@
ur.assign(UtilityRate.wrap(ur_dat).export())
cl.assign(Cashloan.wrap(cl_dat).export())

weather_file = str(Path(__file__).parent.parent / "tests" / "blythe_ca_33.617773_-114.588261_nasa_60_tmy.csv")
pv.SolarResource.solar_resource_file = weather_file

# The models are executed in order. Note that the outputs from the first
# simulation are automatically available for the next one, and so on. :-)
pv.execute()
Expand Down
Loading

0 comments on commit bb95eab

Please sign in to comment.