def run_charging(parvaldic, folder): """ Run the corresponding dymosim.exe with the parameter/value combination from parvaldic and return TOut at the end of the simulation """ cur_dir = os.getcwd() os.chdir(folder) if os.path.exists('success'): os.remove('success') if os.path.exists('failure'): os.remove('failure') for par, val in parvaldic.items(): pymosim.set_par(par, float(val)) pymosim.run_ds(result='run_charging.mat') while True: if os.path.exists('success') or os.path.exists('failure'): break sim = Simulation('run_charging.mat') TOut = sim.get_value('tank.nodes[1].T') os.chdir(cur_dir) return TOut[-1]
def run_charging(parvaldic, folder): """ Run the corresponding dymosim.exe with the parameter/value combination from parvaldic and return TOut at the end of the simulation """ cur_dir = os.getcwd() os.chdir(folder) if os.path.exists('success'): os.remove('success') if os.path.exists('failure'): os.remove('failure') for par, val in parvaldic.items(): pymosim.set_par(par, float(val)) pymosim.run_ds(result='run_charging.mat') while True: if os.path.exists('success') or os.path.exists('failure'): break sim=Simulation('run_charging.mat') TOut = sim.get_value('tank.nodes[1].T') os.chdir(cur_dir) return TOut[-1]
Created on Thu Feb 17 11:36:47 2011 @author: RDC """ import numpy as np import os from awesim import Simulation, Simdex, Process, load_simdex # first, test the package #runfile(r'C:\Workspace\Python\SimulationManagement\test_simman.py', # wdir=r'C:\Workspace\Python\SimulationManagement') # a Simulation is a python object for 1 simulation result file sim=Simulation('LinkedCapacities_A') #with our without .mat extension sim.separate() # optional, makes attributes for parameters and variables sim.parameters sim.variables # in big simulation files, it's not always easy to find the right parameter # or variable sim.exist('q_flow') time = sim.get_value('Time') Q = sim.get_value(u'r.heatPort_a.Q_flow') Q_sum = np.trapz(Q, time) print "The total energy that flowed through the resistance is %.1f J" %Q_sum for p,v in zip(sim.parameters, sim.parametervalues):
Created on Thu Feb 17 11:36:47 2011 @author: RDC """ import numpy as np import os from awesim import Simulation, Simdex, Process, load_simdex # first, test the package #runfile(r'C:\Workspace\Python\SimulationManagement\test_simman.py', # wdir=r'C:\Workspace\Python\SimulationManagement') # a Simulation is a python object for 1 simulation result file sim = Simulation('LinkedCapacities_A') #with our without .mat extension sim.separate() # optional, makes attributes for parameters and variables sim.parameters sim.variables # in big simulation files, it's not always easy to find the right parameter # or variable sim.exist('q_flow') time = sim.get_value('Time') Q = sim.get_value(u'r.heatPort_a.Q_flow') Q_sum = np.trapz(Q, time) print "The total energy that flowed through the resistance is %.1f J" % Q_sum for p, v in zip(sim.parameters, sim.parametervalues):