Пример #1
0
            print("Cell linearization results have been loaded into lins[0] "
                  "through lins[%i]." % (i-1))#, end="")
    else:
        if len(argv) == 1: # Prompt for file.
            fname = fileopenbox(msg="Select a data file.",
                default=os.path.join(default_path, "*.mat"),
                filetypes=['*.mat'])
            # easygui is ugly, but wx seems to make the working session slow:
            #app = App()
            #fname = FileSelector("Select a data file.",
            #    default_path=default_path, wildcard='*.mat')
            if fname == '': _local_exit()
        else:
            fname = argv[1]
        try:
            sim = CellSimRes(fname)
            print('Cell simulation results have been loaded from "%s".\n'
                  'The CellSimRes instance is sim.' % fname)
        except IOError:
            _local_exit()
        except:
            try:
                lin = LinRes(fname)
                print('Cell linearization results have been loaded from
                      '"%s".\nThe CellLinRes instance is lin.' % fname)
            except:
                print('The file, "%s", could not be opened as a cell '
                      'simulation or linearization result.' % fname)
                _local_exit()

    # Open the IPython or standard Python interpreter.
Пример #2
0
import numpy as np

from fcres import CellSimRes

# Chemical components
SPECIES = ['eminus', 'Hplus', 'H2', 'H2O', 'N2', 'O2']
#SPECIES = ['eminus']
TEX = dict(eminus='$e^-$',
           Hplus='$H^+$',
           H2='$H_2$',
           H2O='$H_2O$',
           N2='$N_2$',
           O2='$O_2$')

# Load the results.
sim = CellSimRes("Cell.mat")

# Create plots specific to a single species
for species in SPECIES:
    #sim.plotfig_subregions(species + '.p',
    #                       title="Pressure of %s within Subregions over Time"
    #                             %TEX[species])
    #sim.plotfig_subregions(species + '.T',
    #                       title="Temperature of %s within Subregions over Time"
    #                             %TEX[species])
    sim.quiverfig_subregions(vect=species + '.center.Phi[%i].lower',
                             n_rows=2,
                             times=np.linspace(0, sim.get_FV('Time'), 4),
                             title="Velocity Field of %s" % TEX[species],
                             xlabel="")
Пример #3
0
if run:
    # Create the script to load the packages, simulate, and save the results.
    models, results_dir = gen_sim_script(simspecs, packages=packages,
                                         fname=fname, working_dir=working_dir)

    # Ask Dymola to run the script.
    os.system("bash /opt/dymola/bin/dymola.sh " + fname) # This is for Linux.
    # TODO: Add support for Windows.
else:
    models = [simspec.problem[simspec.problem.rfind('.')+1:] for simspec in simspecs]
    results_dir = os.path.split(fname)[0]

# Create plots.
# Note: The code between the '---' lines must be customized for each simulation
# and plot.
# ------------------------------

## Model 1
label = simspecs[0].resultFile
sim = CellSimRes(os.path.join(results_dir, label))
sim.plotfig(xname='cell.I',
            ynames1='cell.v', ylabel1="Potential", legends1="Average voltage",
            ynames2='cell.Wdot', ylabel2="Power", legends2="Power output",
            title="Cell Polarization", label=label)

# ------------------------------

# Save the plots.
save_figs(formats)
plt.show()
Пример #4
0
    # TODO: Add support for Windows.
else:
    models = [
        simspec.problem[simspec.problem.rfind('.') + 1:]
        for simspec in simspecs
    ]
    results_dir = os.path.split(fname)[0]

# Create plots.
# Note: The code between the '---' lines must be customized for each simulation
# and plot.
# ------------------------------

## Model 1
label = simspecs[0].resultFile
sim = CellSimRes(os.path.join(results_dir, label))
sim.plotfig(xname='cell.I',
            ynames1='cell.v',
            ylabel1="Potential",
            legends1="Average voltage",
            ynames2='cell.Wdot',
            ylabel2="Power",
            legends2="Power output",
            title="Cell Polarization",
            label=label)

# ------------------------------

# Save the plots.
save_figs(formats)
plt.show()