Skip to content

Commit

Permalink
Fix COE input error for RO-FO
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoran29 committed Dec 31, 2021
1 parent 04be715 commit 71ca50f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
2 changes: 0 additions & 2 deletions DesalinationModels/RO_FO.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ def simulation(self, elec_gen, thermal_gen, solar_type = "pv", storage = 0 ): #
simu_output.append({'Name':'External thermal energy usage','Value':fuel,'Unit':'kWh'})
simu_output.append({'Name':'Overall recovery rate','Value':self.design_output[0]['Value'],'Unit':'%'})

print(elec_gen[0:24])
print(elec_load[0:24])
simu_output.append({'Name':'Curtailed solar thermal energy','Value':(sum(thermal_gen) - sum(load)) / 1000000 ,'Unit':'GWh'})
simu_output.append({'Name':'Percentage of curtailed thermal energy','Value':(sum(thermal_gen) - sum(load)) / (sum(thermal_gen)+1) * 100 ,'Unit':'%'})
simu_output.append({'Name':'Curtailed solar electric energy','Value':max(0, (sum(elec_gen) - sum(elec_load))) / 1000000 ,'Unit':'GWh'})
Expand Down
1 change: 0 additions & 1 deletion DesalinationModels/RO_FO_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def lcow(self):
self.FO_CAPEX = ((self.FO_total_CAPEX + self.cost_storage * self.storage_cap)*self.int_rate*(1+self.int_rate)**self.yrs) / ((1+self.int_rate)**self.yrs-1)

self.cost_elec = (self.SEC + self.FO_SEC) * (self.grid_usage * self.coe + (1-self.grid_usage) * self.sam_coe)

self.cost_heat = self.FO_STEC * (self.FO_fuel_usage * self.coh + (1-self.FO_fuel_usage) * self.sam_coh)


Expand Down
3 changes: 0 additions & 3 deletions DesalinationModels/VAGMD_batch/VAGMD_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ def design(self):
self.num_modules = math.ceil(self.Capacity *1000 / (self.AccVd[-1] / self.t[-1] * 24) )
self.ave_stec = sum(self.STEC)/len(self.STEC)
self.PFlux_avg= sum(self.PFlux) / len(self.PFlux)
print(self.FeedC_r)
print('PFlux:', self.PFlux_avg, len(self.PFlux))
print('STEC', self.STEC[-1])
self.df = self.df.round(decimals = 1)
self.df.to_csv(cfg.sam_results_dir/'MDB_output.csv')
self.P_req = self.STEC[-1] * self.Capacity / 24 # kW
Expand Down
2 changes: 0 additions & 2 deletions PSA/SC_ETC_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def lcoh(self):

self.lcoh = self.CAPEX + self.OPEX



cost_output = []
cost_output.append({'Name':'Desal CAPEX','Value':self.CAPEX,'Unit':'$/m3'})
cost_output.append({'Name':'Desal OPEX','Value':self.OPEX,'Unit':'$/m3'})
Expand Down
19 changes: 13 additions & 6 deletions SAM_flatJSON/SamBaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def main(self, param = None):
with open(self.json_values, "r") as read_file:
solar_input = json.load(read_file)

self.staticcollector=StaticCollector_fp(desal_thermal_power_req = solar_input['desal_thermal_power_req'],initial_water_temp = solar_input['initial_water_temp'],outlet_water_temp = solar_input['outlet_water_temp'],cleanless_factor = solar_input['cleanless_factor'],G = solar_input['G'],a = solar_input['a'], b = solar_input['b'], c = solar_input['c'], A = solar_input['A'], file_name = solar_input['file_name'], tilt_angle = solar_input['tilt_angle'], v1 = solar_input['v1'], v2 = solar_input['v2'] , qm = solar_input['qm'], Tamb_D = solar_input['Tamb_D'] )
self.staticcollector=StaticCollector_fp(desal_thermal_power_req = solar_input['desal_thermal_power_req'],
initial_water_temp = solar_input['initial_water_temp'],outlet_water_temp = solar_input['outlet_water_temp'],
cleanless_factor = solar_input['cleanless_factor'],G = solar_input['G'],a = solar_input['a'], b = solar_input['b'], c = solar_input['c'],
A = solar_input['A'], file_name = solar_input['file_name'], tilt_angle = solar_input['tilt_angle'], v1 = solar_input['v1'],
v2 = solar_input['v2'] , qm = solar_input['qm'], Tamb_D = solar_input['Tamb_D'] )
self.heat_gen, self.sc_output = self.staticcollector.design()
filename = 'Solar_output' + self.timestamp +'.json'

Expand All @@ -152,7 +156,8 @@ def main(self, param = None):
with open(finance_model_outfile_path, "r") as read_file:
cost_input = json.load(read_file)

self.collector_cost = ETC_cost(aperture_area = self.sc_output[3]['Value'], non_solar_area_multiplier = cost_input['non_solar_area_multiplier'], capacity = solar_input['desal_thermal_power_req'] * 1000,
self.collector_cost = ETC_cost(aperture_area = self.sc_output[3]['Value'], non_solar_area_multiplier = cost_input['non_solar_area_multiplier'],
capacity = solar_input['desal_thermal_power_req'] * 1000, land_cost = cost_input['land_cost'],
EC = cost_input['EC'], yrs = cost_input['yrs'], int_rate = cost_input['int_rate'], coe = cost_input['coe'], p_OM = cost_input['p_OM'],
unit_cost = cost_input['unit_cost'], cost_boiler = cost_input['cost_boiler'], thermal_gen = sum(self.heat_gen), P_req = self.P_req)
self.cost_out = self.collector_cost.lcoh()
Expand Down Expand Up @@ -195,7 +200,8 @@ def main(self, param = None):
with open(finance_model_outfile_path, "r") as read_file:
cost_input = json.load(read_file)

self.collector_cost = ETC_cost(aperture_area = self.et_output[3]['Value'], non_solar_area_multiplier = cost_input['non_solar_area_multiplier'], capacity = solar_input['desal_thermal_power_req'] * 1000,
self.collector_cost = ETC_cost(aperture_area = self.et_output[3]['Value'], non_solar_area_multiplier = cost_input['non_solar_area_multiplier'],
capacity = solar_input['desal_thermal_power_req'] * 1000, land_cost = cost_input['land_cost'],
EC = cost_input['EC'], yrs = cost_input['yrs'], int_rate = cost_input['int_rate'], coe = cost_input['coe'], p_OM = cost_input['p_OM'],
unit_cost = cost_input['unit_cost'], cost_boiler = cost_input['cost_boiler'], thermal_gen = sum(self.heat_gen), P_req = self.P_req)
self.cost_out = self.collector_cost.lcoh()
Expand Down Expand Up @@ -894,7 +900,8 @@ def cost(self, desal):
FO_labor = self.cost_values_json['FO_labor'], FO_chem_cost = self.cost_values_json['FO_chem_cost'], FO_goods_cost = self.cost_values_json['FO_goods_cost'],
cost_storage = self.cost_values_json['cost_storage'], insurance = self.cost_values_json['insurance'],
FO_SEC = self.cost_values_json['FO_SEC'], FO_capacity = self.design_output[2]['Value'], FO_STEC = self.design_output[8]['Value'], disposal_cost = self.cost_values_json['disposal_cost'],
FO_fuel_usage = self.simu_output[8]['Value'], coe = self.cost_values_json['coe'], solar_coe = self.cost_values_json['solar_coe'], solar_coh = self.cost_values_json['solar_coh'], coh = self.cost_values_json['coh'],sam_coe = self.sam_lcoe, sam_coh = self.sam_lcoh)
grid_usage = self.simu_output[7]['Value'], FO_fuel_usage = self.simu_output[8]['Value'],
coe = self.cost_values_json['coe'], solar_coe = self.cost_values_json['solar_coe'], solar_coh = self.cost_values_json['solar_coh'], coh = self.cost_values_json['coh'],sam_coe = self.sam_lcoe, sam_coh = self.sam_lcoh)
self.cost_output = self.LCOW.lcow()

elif desal == 'RO_MDB':
Expand Down Expand Up @@ -1226,8 +1233,8 @@ def set_data(self, variables):

except Exception as error:
self.logger.critical(error)
print(error)
print(ssc_var)
# print(error)
# print(ssc_var)
# self.logger.info(stringsInJson)
# print(added_variables)

Expand Down
8 changes: 0 additions & 8 deletions SAM_flatJSON/models/inputs/lcoh_calculator_inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
"Require": "*",
"Tab": "Static collector"
},
{
"DataType": "SSC_NUMBER",
"Name": "coe",
"Label": "Unit cost of electricity",
"Units": "$/kWh",
"Require": "*",
"Tab": "Static collector"
},
{
"DataType": "SSC_NUMBER",
"Name": "p_OM",
Expand Down
2 changes: 1 addition & 1 deletion app/app-data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"solar": "SC_FPC", "desal": "FO", "finance": "iph_to_lcoefcr", "parametric": false, "project_name": "Project_1", "timestamp": "2021-12-21_12-52-38", "solar_outfile": "SC_FPC2021-12-21_12-52-38_inputs.json", "desal_outfile": "FO2021-12-21_12-52-38_inputs.json", "finance_outfile": "lcoh_calculator2021-12-21_12-52-38_inputs.json"}
{"solar": "SC_FPC", "desal": "RO_FO", "finance": "iph_to_lcoefcr", "parametric": true, "project_name": "Project_1", "timestamp": "2021-12-30_23-18-00", "solar_outfile": "SC_FPC2021-12-30_23-18-00_inputs.json", "desal_outfile": "RO_FO2021-12-30_23-18-00_inputs.json", "finance_outfile": "lcoh_calculator2021-12-30_23-18-00_inputs.json"}
8 changes: 6 additions & 2 deletions app/apps/model_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,10 @@ def create_tabs_and_tables(x, samjson):
models[1]:solar_model_vars}

def _make_tabs_in_collapse(i):
model_name = {'solar': app['solar'], 'desal': app['desal'], 'finance': app['finance']}
if app['solar'] == "SC_ETC" or app['solar'] == "SC_FPC" :
model_name = {'solar': app['solar'], 'desal': app['desal'], 'finance': "lcoh_calculator"}
else:
model_name = {'solar': app['solar'], 'desal': app['desal'], 'finance': app['finance']}

return dbc.Card(
[
Expand Down Expand Up @@ -800,6 +803,7 @@ def update_model_variables_and_run_model(n_clicks, solTableData, desTableData, f
converted to json and used as input to run the model.
Finally the model is run.
'''

if n_clicks:
#create dict lookups for model and filenames
app = helpers.json_load(cfg.app_json)
Expand Down Expand Up @@ -827,7 +831,7 @@ def update_model_variables_and_run_model(n_clicks, solTableData, desTableData, f
for fR in selectedFinRows:
if fR:
selected_fin.extend(fR)

# pull out variable names and values and add to new dict

for solTable in solTableData:
Expand Down

0 comments on commit 71ca50f

Please sign in to comment.