# -*- coding: utf-8 -*- """Run an example recompression CO2 Brayton cycle sweep.""" from brayton_cycle import BraytonCycle def run_rc_sweep(): brayton = BraytonCycle(name="simple brayton cycle test") T_high = 650 + 273.15 T_low = 42 + 273.15 p_high = 20.0e6 p_low = 9.09e6 ploss = 0.01 fixed_var = { "T_high": T_high, "T_low": T_low, "p_high": p_high / 1e3, "p_low": 8.16e3, "ploss": ploss, } param = { "x": 0.279, "compressor_eff": 0.9, "recompressor_eff": 0.9, "turbine_eff": 0.93, "recuperator_eff": 0.94, "highT_recuperator_eff": 0.96, } brayton.RC(T_low, T_high, p_low / 1e3, p_high / 1e3, ploss, param) Wc = ( brayton.compressor[0].variables["Wc"] + brayton.compressor[1].variables["Wc"] ) Wt = brayton.turbine.variables["Wt"] Q_input = brayton.heater.variables["Q_in"] Q_output = brayton.condenser.variables["Q_out"] print(Q_input + Wc - (Q_output + Wt)) print((Wt - Wc) / Q_input) x_vals, eff_vals, opt_vals = brayton.sweep_and_optimize( fixed_params=fixed_var, params=param, sweep_var="T_low", sweep_bounds=(30 + 273.15, 60 + 273.15), opt_var="x", opt_bounds=(0.1, 0.5), num_points=30, ) return brayton, x_vals, eff_vals, opt_vals if __name__ == "__main__": run_rc_sweep()