-
Notifications
You must be signed in to change notification settings - Fork 50
SAM Cash Flow GUI for Financials
There are many financial outputs in the Singleowner model. This model is based on SAM's Singleowner.
In the SAM GUI, there is a Cash Flow Viewer that facilitates understanding the financial outputs, as shown below. This Wiki shows how to set up a HOPP simulation to export its financial data to this viewer. This has not been rigorously tested for complex financial cases, so if you notice a difference in the finances, please report an issue.
Paste the following code in the script that calls the Singleowner
class after simulate
has been called:
# convert degradation
degradation = []
annual_output = system_model.Outputs.cf_energy_net
for n, energy in enumerate(annual_output[1:]):
degradation.append((1 - annual_output[n+1] / annual_output[1] ) * 100)
financial_model.SystemOutput.degradation = degradation
# export file to be read in by SAM
with open(examples_dir / "singleowner.json", 'w') as f:
dat = financial_model.export()
d = dict()
for k, v in dat.items():
d.update(v)
json.dump(d, f)
Download SAM and Register. Then open SAM, select New Project and create a Generic System, Power Purchase Agreement -> Single owner case.
Create a new Script by selecting File -> New Script and copy in the following code. Set the file path to where the JSON file was exported in Step 1. Then click Run.
dat = json_file("/Users/dguittet/Projects/examples/singleowner.json");
n_years = dat.analysis_period;
gen_len = #dat.gen;
ts_per_year = gen_len / n_years;
single_year_gen = alloc(ts_per_year);
for (i=0; i < ts_per_year; i++)
single_year_gen[i] = dat.gen[i];
keys = @dat;
for (i=0; i < #keys; i++){
set(keys[i], dat{keys[i]});
}
set("derate", 0);
set("grid_interconnection_limit_kwac", 1000*1e3);
set("spec_mode", 1);
set("energy_output_array", single_year_gen);
set("fixed_plant_input", dat.total_installed_cost);
set("genericsys.cost.per_watt", 0 );
set("genericsys.cost.contingency_percent", 0 );
set("genericsys.cost.sales_tax.percent", 0 );
set("heat_rate", 0);
// This sets the construction cost
constr_percent = dat.construction_financing_cost / dat.total_installed_cost;
set("const_per_percent1", constr_percent * 100);
set("const_per_upfront_rate1", 100);
set("const_per_months1", 0);
set("const_per_interest_rate1", 0);
set("const_per_percent2", 0);
set("const_per_percent3", 0);
set("const_per_percent4", 0);
set("const_per_percent5", 0);
Switch to the main SAM Window and click Simulate at the bottom left. Then go to the Cash Flow tab. From here you can also export the results to CSV.