Skip to content

Commit d269cab

Browse files
authored
PySAM documentation revisions (#120)
1 parent cb77a8d commit d269cab

34 files changed

+1290
-1321
lines changed

docs/Configs.rst

Lines changed: 0 additions & 478 deletions
This file was deleted.

docs/Examples.rst

Lines changed: 10 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,19 @@
1-
.. Examples:
1+
Code Examples
2+
==============
23

3-
Examples
4-
========
4+
.. note::
5+
This section is a draft to be revised and expanded.
56

6-
There are a few example python scripts using PySAM in the Examples directory of the github repository.
7+
For PySAM code examples see the `PySAM repository on GitHub <https://github.com/NREL/pysam/tree/master/Examples>`_.
78

8-
Accessing Variables
9-
*******************
9+
Generate Inputs for a REopt API Call
10+
-------------------------------------
1011

11-
All variables in a PySAM class are organized into subclasses called Groups.
12-
There are several ways to access a variable. The subclass and variable names
13-
and descriptions are given in the :doc:`Models` documentation.
12+
The Pvwattsv8 and Pvsamv1 compute modules, when used in a configuration with battery storage, have and option to size and dispatch the battery using the `ReOpt API <https://developer.nrel.gov/docs/energy-optimization/reopt-v1/>`_.
1413

15-
Variables may be accessed directly as `<class>.<subclass>.<variable>`.
16-
For example, `the solar_resource_file` which is part of the subclass `SolarResource` group in Pvwattsv7::
14+
This basic code example shows how to use the ``Reopt_size_battery_post()`` function in preparation for a call to the REopt API. The function returns a dictionary of REopt inputs that can be converted to JSON for the API call. A complete model would require the ``Utilityrate5`` compute module for electricity bill calculations, and the ``Cashloan`` module for cash flow calculations.
1715

18-
import PySAM.Pvwattsv8 as pv
19-
20-
system_model = pv.new()
21-
system_model.SolarResource.solar_resource_file
22-
23-
24-
Groups and variables can also be accessed using `getattr`. Variables can be set with `setattr`::
25-
26-
getattr(getattr(system_model, 'SolarResource'), 'solar_resource_file')
27-
setattr(getattr(system_model, 'SolarResource'), 'solar_resource_file', filename)
28-
29-
If the group name isn't known, a variable can be accessed using `value`::
30-
31-
system_model.value('solar_resource_file')
32-
33-
filename = 'My_TMY_or_TYA_File'
34-
# This is how you would assign the variable, solar_resource_file to your own file name.
35-
system_model.value('solar_resource_file', filename)
36-
37-
38-
The `assign` and `export` functions can be used to work with groups of variables in dictionaries::
39-
40-
systemDesign = {'azimuth':100, 'gcr': .5} # ground coverage ratio
41-
system_model.SystemDesign.assign(systemDesign)
42-
system_model.SystemDesign.export()
43-
44-
Creating a Simulation from Multiple Modules
45-
*******************************************
46-
47-
48-
Suppose you wish to create a PV Power Purchase Agreement (PPA) single owner
49-
plant simulation. First you go to :doc:`Configs`, where you find the modules you
50-
need for this simulation are Pvwattsv7, and Singleowner in that order. In this
51-
simple example the values are loaded from the set of default parameters in the
52-
configuration "PVWattsSingleOwner". The docs listing possible configurations of
53-
the modules are found in the documentation for those :doc:`Models`; for example,
54-
for Pvwattsv7 they are found in :doc:`modules/Pvwattsv7`. There is a
55-
configuration for each of the types of simulations listed in :doc:`Configs`.
56-
57-
The Singleowner model is created using the `from_existing` function so that it
58-
shares the same underlying data as the
59-
PVwattsv7 model. This means when the Pvwattsv7 model is executed, the data for
60-
the financial Singleowner model is loaded from its outputs. The execute
61-
functions for each model are called sequentially to do the simulation.::
62-
63-
import PySAM.Pvwattsv8 as pv
64-
import PySAM.Singleowner as so
65-
66-
system_model = pv.default('PVWattsSingleOwner')
67-
financial_model = so.from_existing(system_model, 'PVWattsSingleOwner')
68-
69-
filename = 'My_TMY_or_TYA_File'
70-
system_model.SolarResource.solar_resource_file = filename
71-
72-
system_model.execute()
73-
financial_model.execute()
74-
75-
print(system_model.Outputs.ac_annual, financial_model.Outputs.ppa)
76-
77-
78-
Importing a SAM GUI Case
79-
************************
80-
81-
Entering or changing all the data describing your simulation from default values
82-
can be tedious, and make your python script less readable. An alternative is to
83-
use the SAM GUI to enter the data, and then to save the inputs as a JSON file.
84-
This file can then be imported into PySAM, making for less tedium.
85-
For an example of how to import the modules and variables from a SAM GUI Case, see :doc:`Import`.
86-
87-
88-
Sizing a PV + Battery system with ReOpt
89-
***************************************
90-
91-
Pvwattsv8 and Pvsamv1 have the option to size and dispatch a StandAloneBattery
92-
or Battwatts model from `ReOpt Lite's <https://developer.nrel.gov/docs/energy-optimization/reopt-v1/>`_ optimization.
93-
The Utilityrate5 model is also required to provide electric tariff
94-
info, and other financial models
95-
such as Cashloan may also be linked to provide financial parameters. The
96-
`Reopt_size_battery_post` function returns
97-
a properly-formatted dictionary of ReOpt inputs that can then be posted to the
98-
`ReOpt Lite's API <https://github.com/NREL/REopt-API-Analysis>`_ as a json string::
16+
.. code:: python
9917
10018
import PySAM.Utilityrate5 as ur
10119
import PySAM.Pvsamv1 as pvsam
@@ -111,6 +29,3 @@ a properly-formatted dictionary of ReOpt inputs that can then be posted to the
11129
11230
battery_model.Load.crit_load = [0] * 8760
11331
post = system_model.Reopt_size_battery_post()
114-
115-
116-

docs/GettingStarted.rst

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/Import.rst

Lines changed: 0 additions & 117 deletions
This file was deleted.

docs/Initialization.rst

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)