コード例 #1
0
 def test_exist_array(self):
     """
     For a simulation file which uses arrays, Test if :
     1) running Simulation.exist() gives a match when it should
        (different cases are tested)
     2) running Simulation.exist() gives a zero list for non-pressent regex
     
     """
     
     sim = Simulation('Array')
     self.assertEqual(sim.names[1], sim.exist(sim.names[1])[0], 
                      'Simulation.exist() does NOT return a present name')
     self.assertEqual(4, len(sim.exist('heatport.q_flow')), 
                      "sim.exist('heatport.q_flow') should give 4 matches")
     self.assertEqual(12, len(sim.exist('[1]')), 
                      "sim.exist('[1]') should give 12 matches")
コード例 #2
0
 def test_exist_array(self):
     """
     For a simulation file which uses arrays, Test if :
     1) running Simulation.exist() gives a match when it should
        (different cases are tested)
     2) running Simulation.exist() gives a zero list for non-pressent regex
     
     """
     
     sim = Simulation('Array')
     self.assertEqual(sim.names[1], sim.exist(sim.names[1])[0], 
                      'Simulation.exist() does NOT return a present name')
     self.assertEqual(4, len(sim.exist('heatport.q_flow')), 
                      "sim.exist('heatport.q_flow') should give 4 matches")
     self.assertEqual(12, len(sim.exist('[1]')), 
                      "sim.exist('[1]') should give 12 matches")
コード例 #3
0
 def test_exist(self):
     """
     Test if :
     1) running Simulation.exist() gives a match when it should
        (different cases are tested)
     2) running Simulation.exist() gives a zero list for non-present regex
     
     """
     
     sim = Simulation('LinkedCapacities')
     self.assertEqual(sim.names[1], sim.exist(sim.names[1])[0], 
                      'Simulation.exist() does NOT return a present name')
     self.assertEqual(5, len(sim.exist('c1')), "sim.exist('c1') should give \
                      5 matches")
     self.assertEqual(u'Time', sim.exist('time')[0], 
                      'Simulation.exist() should ignore case' )
     self.assertEqual([], sim.exist('something that does not exist'))
コード例 #4
0
 def test_exist(self):
     """
     Test if :
     1) running Simulation.exist() gives a match when it should
        (different cases are tested)
     2) running Simulation.exist() gives a zero list for non-present regex
     
     """
     
     sim = Simulation('LinkedCapacities')
     self.assertEqual(sim.names[1], sim.exist(sim.names[1])[0], 
                      'Simulation.exist() does NOT return a present name')
     self.assertEqual(5, len(sim.exist('c1')), "sim.exist('c1') should give \
                      5 matches")
     self.assertEqual(u'Time', sim.exist('time')[0], 
                      'Simulation.exist() should ignore case' )
     self.assertEqual([], sim.exist('something that does not exist'))
コード例 #5
0
# 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):
    print ''.join([p, ' = ', str(v)])

# there are different ways to create a simdex

s1 = Simdex()  # an empty simdex object
s1.scan(
)  # scan current folder and add all found simulation files to the simdex
コード例 #6
0
# 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):
    print ''.join([p, ' = ', str(v)])


# there are different ways to create a simdex

s1 = Simdex() # an empty simdex object
s1.scan() # scan current folder and add all found simulation files to the simdex