コード例 #1
0
def first_replicate(initial_pressure, initial_temperature, fuel_string,
                    oxidizer_string, equivalence_list, current_diluent,
                    diluent_mf_list, tube_volume_m3, df, call_number, mp_out):

    # initialize a detonation
    my_detonation = det.Detonation(initial_pressure, initial_temperature,
                                   fuel_string, oxidizer_string)

    # build list of all test combinations
    test_conditions = list(
        itertools.product(
            *[equivalence_list, [current_diluent], diluent_mf_list]))

    for j in xrange(len(test_conditions)):
        # select a random test condition
        [equivalence, diluent,
         mf] = test_conditions.pop(random.randrange(len(test_conditions)))
        data = [diluent, equivalence, mf, [], [], [], [], [], [], []]

        # update detonation for each diluent, equivalence, and mf
        if current_diluent is 'None':
            # undiluted case
            diluted = False
            pass

        else:
            # diluted case
            my_detonation.set_equivalence(equivalence)
            my_detonation.add_diluent(diluent, mf)
            diluted = True

        # calculate partial pressures of each component. Filling
        # will be done fuel -> oxidizer -> diluent, so partials
        # will be added in this order in order to get cutoff
        # pressures for each component.
        pressures = my_detonation.get_pressures(diluted)
        data[3] = pressures[fuel_string]
        data[4] = data[3] + pressures[oxidizer_string]
        try:
            data[5] = data[4] + pressures[current_diluent]
        except:
            data[5] = 'N/A'

        # calculate cj
        data[6] = my_detonation.CJ_Velocity(diluted).value
        # calculate mass used
        masses = my_detonation.get_mass(tube_volume_m3, diluted)
        data[7] = masses[fuel_string]
        data[8] = masses[oxidizer_string]
        try:
            data[9] = masses[current_diluent]
        except:
            data[9] = 0.
        # put into sheet
        df.add_row(data)
    mp_out.put_nowait((call_number, df))
コード例 #2
0
ファイル: show_status.py プロジェクト: zingale/Castro
#!/bin/env python3

import glob
import tqdm

import detonation as dt

if __name__ == "__main__":

    # get all the data
    run_dirs = glob.glob("det_[rst]*")
    dets = []
    for run in tqdm.tqdm(run_dirs):
        dets.append(dt.Detonation(run))

    for det in sorted(dets):

        if det.crashed:
            print("{:55} : crashed".format(det.name))
        elif det.has_started:
            print("{:55} : t = {:8.5f}, # of steps = {:5}, v = {:15.8g} +/- {:15.8g}".format(det.name, det.end_time, det.nsteps, det.v, det.v_sigma))
        else:
            print("{:55} : has not started".format(det.name))
コード例 #3
0
def first_replicate(initial_pressure, initial_temperature, fuel_string,
                    oxidizer_string, equivalence_list, current_diluent,
                    diluent_mf_list, tube_volume_m3, df, call_number, mp_out):

    # initialize a detonation
    my_detonation = det.Detonation(initial_pressure, initial_temperature,
                                   fuel_string, oxidizer_string)

    # no diluent means no diluent mass fraction
    if current_diluent == 'None':
        diluent_mf_list = [0]

    # build list of all test combinations
    test_conditions = list(
        itertools.product(
            *[equivalence_list, [current_diluent], diluent_mf_list]))

    for j in xrange(len(test_conditions)):
        # select a random test condition
        [equivalence, diluent,
         mf] = test_conditions.pop(random.randrange(len(test_conditions)))
        data = [diluent, equivalence, mf, [], [], [], [], [], [], []]

        # update detonation for each diluent, equivalence, and mf
        my_detonation.set_equivalence(equivalence)
        if current_diluent == 'None':
            # undiluted case
            diluted = False

        else:
            # diluted case
            my_detonation.add_diluent(diluent, mf)
            diluted = True

        # calculate partial pressures of each component. Filling
        # will be done fuel -> oxidizer -> diluent, so partials
        # will be added in this order in order to get cutoff
        # pressures for each component.
        pressures = my_detonation.get_pressures(diluted)
        masses = my_detonation.get_mass(tube_volume_m3, diluted)
        if current_diluent == 'AR' and equivalence == 1 and mf == 0.2:
            print masses
            print my_detonation.diluted.mole_fraction_dict()
            print tube_volume_m3, diluted
            for i, species in enumerate(my_detonation.diluted.species_names):
                if my_detonation.diluted.X[i] > 0:
                    print species
                    print '    conx:', my_detonation.diluted.concentrations[i]
                    print '      mw:', my_detonation.diluted.molecular_weights[
                        i]
        data[3] = pressures[fuel_string]
        data[4] = data[3] + pressures[oxidizer_string]
        try:
            data[5] = data[4] + pressures[current_diluent]
        except (KeyError):
            data[5] = 'N/A'

        # calculate cj
        data[6] = 0  # my_detonation.CJ_Velocity(diluted).value
        # calculate mass used
        data[7] = masses[fuel_string]
        data[8] = masses[oxidizer_string]
        try:
            data[9] = masses[current_diluent]
        except (KeyError):
            data[9] = 0.
        # put into sheet
        df.add_row(data)
    sys.stdout.flush()
    #    mp_out.put((call_number, df))
    return (call_number, df)