def parameter_sweep(sweep_input, debug=True):
    start = time.time()

    if sweep_input['m_dot'] > 0.0 and sweep_input['r_f'] > 0.0:

        # create system
        inputs = ICAES2.get_default_inputs()

        # uncertainty parameters - general
        inputs['T_grad_m'] = sweep_input['T_grad_m']  # [C/km]
        inputs['p_hydro_grad'] = sweep_input['p_hydro_grad']  # [MPa/km]
        inputs['p_frac_grad'] = sweep_input['p_frac_grad']  # [MPa/km]
        inputs['loss_m_air'] = sweep_input['loss_m_air']  # [-]

        # uncertainty parameters - location-specifc
        inputs['depth'] = sweep_input['depth_m']  # [m]
        inputs['h'] = sweep_input['thickness_m']  # [m]
        inputs['phi'] = sweep_input['porosity']  # [-]
        inputs['k'] = sweep_input['permeability_mD']  # [mD]

        # machinery polytropic index
        inputs['n_cmp1'] = sweep_input['n_cmp1']
        inputs['n_exp1'] = sweep_input['n_exp1']

        # design inputs
        inputs['m_dot'] = sweep_input['m_dot']  # [kg/s]
        inputs['r_f'] = sweep_input['r_f']  # [m]

        # all other parameters - taken as default
        system = ICAES2(inputs=inputs)

        # run single cycle and analyze
        try:
            system.single_cycle()
            results = system.analyze_performance()

            end = time.time()
            results['solve_time'] = end - start

            # print out RTE
            print(results['RTE'])

            # combine inputs and results to return in single series
            single_output = pd.concat([sweep_input, results])
        except:
            single_output = sweep_input
    else:
        single_output = sweep_input
    return single_output
Exemple #2
0
def sensitivity(sensitivity_input):
    start = time.time()

    # create system
    inputs = ICAES2.get_default_inputs()
    for variable in sensitivity_input.index:
        inputs[variable] = sensitivity_input[variable]
    system = ICAES2(inputs=inputs)

    # run single cycle and analyze
    system.single_cycle()
    results = system.analyze_performance()
    end = time.time()
    results['solve_time'] = end - start

    # combine inputs and results to return in single series
    single_output = pd.concat([sensitivity_input, results])
    return single_output
Exemple #3
0
k = 236.1424  # [mD]
capacity = 200  # [MW]
duration = 24  # [hr]
r_w = 0.41 / 2.0  # [m]
m_dot = 619.6078491  # mass flow rate [kg/s]
r_f = 82.64452305  # formation radius [m]

timesteps_to_try = [
    1, 2, 5, 10, 50, 75, 100, 125, 200, 300, 400, 500, 600, 700, 800, 900, 1000
]

df = pd.DataFrame()

for timesteps in timesteps_to_try:
    # create system
    inputs = ICAES2.get_default_inputs()
    inputs['depth'] = depth
    inputs['h'] = h
    inputs['phi'] = phi
    inputs['k'] = k
    inputs['r_f'] = r_f
    inputs['r_w'] = r_w
    inputs['m_dot'] = m_dot
    inputs['steps'] = timesteps

    system = ICAES2(inputs=inputs)

    # run single cycle and analyze
    system.single_cycle()
    results = system.analyze_performance()
    RTE = results['RTE']
Exemple #4
0
def parameter_sweep(sweep_input, debug=True):
    start = time.time()

    # convert inputs to model units
    kW_out = sweep_input['capacity_MW'] * 1e3
    kWh_out = sweep_input['capacity_MW'] * sweep_input['duration_hr'] * 1e3
    if debug:
        print('\nStarting sizing')
        print("kW_out (desired) : " + str(round(kW_out, 3)))
        print("kWh_out (desired): " + str(round(kWh_out, 3)))
        print("\nDepth (m)      : " + str(sweep_input['depth_m']))
        print("Thickness (m)    : " + str(sweep_input['thickness_m']))
        print("Porosity (-)     : " + str(sweep_input['porosity']))
        print("Permeability (mD): " + str(sweep_input['permeability_mD']))
        print("Well radius (m)  : " + str(sweep_input['r_w']))

    # allowable calculation error
    error = 1e-6

    # maximum number of iterations
    count_max = 200

    # initial guesses
    m_dot = 10.0
    r_f = 10.0

    # initial results
    kW_out_actual = 0.0
    kWh_out_actual = 0.0

    count = 0
    while abs(kW_out_actual - kW_out) / kW_out + abs(
            kWh_out_actual - kWh_out) / kWh_out > error:
        if debug:
            print("\nIteration : " + str(count))
            print("m_dot       : " + str(round(m_dot, 3)))
            print("r_f         : " + str(round(r_f, 3)))

        # create system
        inputs = ICAES2.get_default_inputs()
        # user inputs
        inputs['depth'] = sweep_input['depth_m']  # porosity depth [m]
        inputs['h'] = sweep_input['thickness_m']  # porosity thickness [m]
        inputs['phi'] = sweep_input['porosity']  # formation porosity [-]
        inputs['k'] = sweep_input[
            'permeability_mD']  # formation permeability [mD]
        inputs['r_w'] = sweep_input['r_w']  # well radius [m]

        # machinery polytropic index
        inputs['n_cmp1'] = sweep_input['n_cmp1']
        inputs['n_exp1'] = sweep_input['n_exp1']

        # current guess/iteration
        inputs['m_dot'] = m_dot  # [kg/s]
        inputs['r_f'] = r_f  # [m]
        system = ICAES2(inputs=inputs)

        # run single cycle and analyze
        system.single_cycle()
        results = system.analyze_performance()

        # extract results of interest
        kW_out_actual = results['kW_out_avg']
        kWh_out_actual = results['kWh_out']

        # update guesses
        tau = 0.5  # solver time constant
        m_dot = m_dot * (1.0 + tau * (kW_out - kW_out_actual) / kW_out
                         )  # m_dot linearly linked to kW
        r_f = r_f * (1.0 + tau**2 * (kWh_out - kWh_out_actual) / kWh_out_actual
                     )  # r_f exponentially linked to kWh

        count = count + 1
        if count > count_max:  # sizing unsuccessful
            results['errors'] = True
            break

        if debug:
            print("MW_out_avg   : " + str(round(kW_out_actual / 1e3, 3)))
            print("MWh_out      : " + str(round(kWh_out_actual / 1e3, 3)))

    end = time.time()
    results['solve_time'] = end - start
    results['iterations'] = count
    results['m_dot'] = m_dot
    results['r_f'] = r_f

    # print out RTE
    print(results['RTE'])

    # combine inputs and results to return in single series
    single_output = pd.concat([sweep_input, results])
    return single_output