Closed dpinney closed 9 years ago
What's really needed is the SDK: https://sam.nrel.gov/sdk
Just make a new solver nrelsam5
by copying existing solver, updating SDK files, then switching imports.
Functionality for the following models breaks on Linux: pvWatts solarRates/Financial/Sunda
Only one vague error is displayed: Log Notice: precheck input: variable 'solar_resource_file' required but not assigned time -1
Which appears in terminal - no errors logged in stderr.txt.
In an attempt to debug further I tried it with the last 4 SDKs - the last 3 versions: 2015-6-30, 2015-1-30, and 2014-11-24 fail, but 2014-1-21 does not fail. 2014-1-21 does not seem to be the version we are using live right now because of the difference in file sizes.
What would you suggest as the next course of action?
Pretty sure they changed the "file_name" parameter to "solar_resource_file" parameter.
So change:
ssc.ssc_data_set_string(dat, "file_name", modelDir + "/climate.tmy2")
to:
ssc.ssc_data_set_string(dat, "solar_resource_file", modelDir + "/climate.tmy2")
The correct way to update an API is to keep both parameters, put a warning on the old one...
That worked like a charm. It also needed a parameter for adjust:constant, with that on their all models work and have results identical to before. So with the following parameters:
ssc.ssc_data_set_string(dat, "solar_resource_file", modelDir + "/climate.tmy2")
ssc.ssc_data_set_number(dat, "adjust:constant", -25.0)
The rest work fine, and only adding adjust:constant is necessary. I can't figure out how to have the user select a nrelsam version though, the solver sdk is selected in the init_.py script in the nrelsam folder, which it appears is only loaded during OMF startup. Could it be passed to the SSCAPI class here (My knowledge of classes is limited)?
myDir = os.path.dirname(__file__)
c_number = c_float # must be c_double or c_float depending on how defined in sscapi.h
class SSCAPI():
# User selects version by setting pvWattsv here
pvWattsv = "nrelsam5"
myDir = os.path.join(myDir, pvWattsv)
print "\n myDir=", myDir
if sys.platform == 'win32' or sys.platform == 'cygwin':
if 8*struct.calcsize("P") == 64:
_dll = CDLL(os.path.join(myDir,"ssc64.dll"))
else:
_dll = CDLL(os.path.join(myDir,"ssc32.dll"))
# return _dll
elif sys.platform == 'darwin':
_dll = CDLL(os.path.join(myDir,"ssc64.dylib"))
# return _dll
elif sys.platform == 'linux2':
_dll = CDLL(os.path.join(myDir,"ssc64.so"))
# return _dll
else:
print "Platform not supported ", sys.platform
# print "\n _dll chosen=", _dll, "(for ", sys.platform, ")"
The two solver versions are in: solvers->nrelsam->[nrelsam1] or [nrelsam5].
Oh I think if it is moved to importing this is resolved, so import becomes:
from solvers import nrelsamv1, nrelsamv5
And selection is now done from here. This by default selects the nrelsam5 and hasn't broke yet. Next, we could add the ability for the user to select which version he/she wants to run from a drop-down on the inputs page.
I have it setup as follows:
from solvers import nrelsam, nrelsam5
...
#from user selection
pvWattsV = "nrelsam1"
# PVWattsv5
if (pvWattsV == "nrelsam5"):
# Set up SAM data structures.
ssc = nrelsam5.SSCAPI()
dat = ssc.ssc_data_create()
# Required user inputs.
ssc.ssc_data_set_string(dat, "solar_resource_file", modelDir + "/climate.tmy2")
ssc.ssc_data_set_number(dat, "adjust:constant", 0.0)
warnings.warn("The solver nrelsamv5 is selected.", RuntimeWarning)
# PVWatsv1
else:
# Set up SAM data structures.
ssc = nrelsam.SSCAPI()
dat = ssc.ssc_data_create()
# Required user inputs.
ssc.ssc_data_set_string(dat, "file_name", modelDir + "/climate.tmy2")
warnings.warn("The solver nrelsamv1 is selected.", RuntimeWarning)
...
I think the warning isn't necessary any longer.
Great work. I think we should discuss this in person because there are a bunch of design choices now (which version to use by default, any v5 features we should use, should we allow users to choose their version, do we ignore warnings in the production web server logs, etc.). I'll be free later today around 2 PM, or we can try for some time Monday.
Notes after our discussion:
One concern -- losses and inverter efficiency are treated differently in the two models, so we will need to change input screens to accommodate the new format.
I think Mannan found an elegant solution for that. @drdanley and @mannanj, work together to make sure the losses and efficiency inputs are okay with the new version.
Yes I believe this has been resolved. Losses and efficiency are now input as whole percentages, and previously called "derates" is now "losses" and was the system efficiency (i.e. 97% efficient system from soiling, pvshading, etc. with 3% losses but input into system as 97% derate) is now losses of 3%. I can meet to verify this in person tomorrow.
I think this is working and commited; it could be closed once confirmed working in production. @dpinney can you take the issue?
Note: Encountered a bug on Fathalla's windows PC being unable to load the 32-bit solver. This may require some troubleshooting. It does work on a windows 7 virtual environment.
Debian Wheezy is incompatible with NREL SAM's 2015 release. We'll consider an upgrade later.
TODO
QUESTIONS