Example #1
0
    # TODO: find way to have conditional arguments based off of what xaxis and yaxis are
    # (in other words, we have an excess of variables as arguments)
    my_parser = Plot3D()

    args = vars(my_parser.parse_args())
    assert args['yaxis'], 'No y axis chosen for plot'
    assert args['xaxis'], 'No x axis chosen for plot'

    my_plotter = Plotter(**args)
    my_plotter.read_json()

    boxFrom, boxTo = args['boxes']
    mol1, mol2 = args['molecules']
    kwargs = {'boxFrom': boxFrom, 'boxTo': boxTo, 'mol1': mol1, 'mol2': mol2}

    data = {'x': {}, 'y': {}, 'z': {}}
    for feed in args['feeds']:
        file_name = ''
        # determine if run has been completed
        my_plotter.run = checkRun(args['type'], my_plotter.variables, feed)
        my_plotter.feed = feed
        for axis in ['x', 'y', 'z']:
            kwargs['mol'] = args['mol%s' % axis]
            kwargs['box'] = args['box%s' % axis]
            file_name += 'mol%s-box%s-%s_' % (kwargs['mol'], kwargs['box'],
                                              args['%saxis' % axis])
            data[axis][feed] = my_plotter.convertChoice(
                args['%saxis' % axis], **kwargs)
    write(data, file_name + '.dat',
          my_plotter.gen_data[my_plotter.feed][my_plotter.run]['numIndep'])
Example #2
0
    my_data.variables.append(my_data.P)
    my_data.read_json()

    # gather data
    temperatures = []
    gas_densities = {
        'mean': [],
        'error': []
    }
    liquid_densities = {
        'mean': [],
        'error': []
    }
    pressures = {'mean': [], 'error': []}
    for feed, T in zip(args['feeds'], args['temperatures']):
        my_data.run = checkRun(args['type'], my_data.variables, feed)
        my_data.feed = feed
        rhoG, drhoG, rhoL, drhoL, p, dp = getResults(my_data, args['mol'],
                                                     args['molWeight'])
        temperatures.append(T)
        gas_densities['mean'].append(rhoG)
        gas_densities['error'].append(drhoG)
        liquid_densities['mean'].append(rhoL)
        liquid_densities['error'].append(drhoL)
        pressures['mean'].append(p)
        pressures['error'].append(dp)

    # write to file
    with open('vlcc.inp', 'w') as f:
        f.write(str(args['feeds']) + str(args['temperatures']) + '\n')
        f.write('NDATA  BETA    NITER\n')
Example #3
0
    rho = {}
    C = {}
    gen_data = {}
    for file, var in zip(['rho-data.db', 'Conc-data.db', 'general-data.db'],
                         [rho, C, gen_data]):
        with shelve.open('%s/%s' % (args['path'], file)) as db:
            for feed in args['feeds']:
                assert feed in db.keys(), 'Feed {} not in database'.format(
                    feed)
                var[feed] = db[feed]

    mol_data = {}
    for feed in args['feeds']:
        # determine if run has been completed
        run = checkRun(args['type'], [C, rho], feed)
        # gen data
        numIndep = gen_data[feed][run]['numIndep']
        # concentrations
        conc, c_mol, box = getX(C[feed])
        # initialize variables if needed
        if c_mol not in mol_data.keys():
            mol_data[c_mol] = {}
            for key in ['kH', 'P']:
                mol_data[c_mol][key] = {'mean': [], '95conf': [], 'feed': []}
        henry_constant = mol_data[c_mol]['kH']
        pressure = mol_data[c_mol]['P']
        rho_mean, rho_stdev = (rho[feed][run][c_mol]['box3']['mean'],
                               rho[feed][run][c_mol]['box3']['stdev'])
        # convert number density to pressure [kPa]
        # (molec/nm**3)*(mol/molec)*(nm**3*kPa/(mol*K))*K = kPa
Example #4
0
    plt.subplots_adjust(left=0.11, right=0.97, top=0.97, bottom=0.5)
    fig = plt.gcf()
    fig.set_size_inches(6.5, 6.5)
    fig.savefig('%s-%s.png' % (feed, run), dpi=300)
    plt.show()


import math, random
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
    import argparse, os, shelve
    from MCFlow.runAnalyzer import checkRun
    parser = argparse.ArgumentParser(
        description='plot swap and swatch accptances for given feed')
    parser.add_argument('-f',
                        '--feed',
                        help='feed to analyze swaps and swatches for')
    parser.add_argument('-t',
                        '--type',
                        help='type of run to analyze',
                        default='equil-')
    args = vars(parser.parse_args())

    assert os.path.isfile('SWAP-data.db'), 'No SWAP data found'
    with shelve.open('SWAP-data.db') as db:
        assert args['feed'] in db.keys(), 'Feed not in database'
        data = {args['feed']: db[args['feed']]}
    my_run = checkRun(args['type'], [data], args['feed'])
    plot_transfer_acceptance(data[args['feed']][my_run], args['feed'], my_run)