├── .gitignore ├── Readme.rst ├── Readme.rst~ ├── awesim ├── __init__.py ├── process.py ├── pymosim.py ├── result.py ├── simdex.py ├── simman.py ├── simulation.py └── utilities.py ├── doc ├── Makefile ├── Simulation_demo.ipynb ├── build │ ├── doctrees │ │ ├── class_overview.doctree │ │ ├── environment.pickle │ │ ├── index.doctree │ │ ├── process.doctree │ │ └── simulation.doctree │ └── html │ │ ├── .buildinfo │ │ ├── _modules │ │ ├── awesim.html │ │ └── index.html │ │ ├── _sources │ │ ├── class_overview.txt │ │ ├── index.txt │ │ ├── process.txt │ │ └── simulation.txt │ │ ├── _static │ │ ├── ajax-loader.gif │ │ ├── basic.css │ │ ├── comment-bright.png │ │ ├── comment-close.png │ │ ├── comment.png │ │ ├── default.css │ │ ├── doctools.js │ │ ├── down-pressed.png │ │ ├── down.png │ │ ├── file.png │ │ ├── jquery.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── sidebar.js │ │ ├── underscore.js │ │ ├── up-pressed.png │ │ ├── up.png │ │ └── websupport.js │ │ ├── class_overview.html │ │ ├── genindex.html │ │ ├── index.html │ │ ├── objects.inv │ │ ├── process.html │ │ ├── search.html │ │ ├── searchindex.js │ │ └── simulation.html └── source │ ├── DemoProcess.py │ ├── Overview.emf │ ├── Overview.graphml │ ├── Simdex_attributes.graphml │ ├── Simdex_methods.graphml │ ├── class_overview.rst │ ├── conf.py │ ├── index.rst │ ├── ipython_console_highlighting.py │ ├── ipython_directive.py │ ├── process.rst │ └── simulation.rst ├── examples ├── DemoProcess.py └── demo_simman.py ├── scipymio4.patch ├── scripts ├── ParRunPostProc.py ├── ParametricRun.py ├── SensitivityRun.py └── solvertest.py └── tests ├── Array.mat ├── LinkedCapacities.mat ├── LinkedCapacities_A.mat ├── LinkedCapacities_B.mat ├── LinkedCapacities_C.mat ├── LinkedCapacities_D.mat ├── LinkedCapacities_E.mat ├── LinkedCapacities_F.mat ├── PythonTestPackage.mo ├── ResultFileTxtFormat.txt ├── SubfolderWithCrappyFiles ├── Array.mat ├── EmptyMatFile.mat ├── LinkedCapacities.mat ├── LinkedCapacities_A.mat ├── LinkedCapacities_B.mat ├── LinkedCapacities_C.mat ├── LinkedCapacities_D.mat ├── LinkedCapacities_D_TooShort.mat ├── LinkedCapacities_E.mat └── LinkedCapacities_F.mat ├── TestSet2 └── reswithCPUtime.mat └── test_awesim.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | *.pyc 3 | *.log 4 | dsfinal.txt 5 | dsin.txt 6 | dslog.txt 7 | dsmodel.c 8 | dymosim.exe 9 | buildlog.txt 10 | /ProblemToBeSolvedASAP.py 11 | /Subfolder/SubfolderForArray_Big/Array_Big.mat 12 | /Test_save.dat 13 | /SpeedInvestigations.xlsx 14 | *.dat 15 | *.h5 16 | /outputfile.txt 17 | /doc/make.bat 18 | /tests/SpeedInvestigations.xlsx 19 | /doc/Untitled0.ipynb 20 | /tests/SSB_files/SSB_5_HeatingCurve_F24H.mat 21 | /tests/SSB_files/SSB_6_HeatingCurve_Ref - Copy.mat 22 | /tests/SSB_files/TME_SSB_5_34degdata.mat 23 | /tests/SSB_files/TME_SSB_5_DayTime_5000W_R10_3.mat 24 | /tests/SSB_files/TME_SSB_5_DayTime_5000W_R10_4.mat 25 | /tests/SSB_files/TME_SSB_5_DayTime_R5_1.mat 26 | /tests/SSB_files/TME_SSB_5_DayTime_R5_2.mat 27 | /tests/SSB_files/TME_SSB_5_DayTime_R5_3.mat 28 | /tests/SSB_files/TME_SSB_5_DayTime_R5_4.mat 29 | /tests/SSB_files/TME_SSB_5_DayTime_R5_5.mat 30 | /tests/SSB_files/TME_SSB_5_GridLoad_4.mat 31 | /tests/SSB_files/TME_SSB_5_GridLoad_5.mat 32 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_19.mat 33 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_20.mat 34 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_1.mat 35 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_2.mat 36 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_3.mat 37 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_4.mat 38 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_5.mat 39 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_6.mat 40 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_7.mat 41 | /tests/SSB_files/TME_SSB_5_GridLoad_5000W_B3000_8.mat 42 | /tests/SSB_files/TME_SSB_5_HeatingCurve_4000W_Ref.mat 43 | /tests/SSB_files/TME_SSB_6_DayTime_4.mat 44 | /tests/SSB_files/TME_SSB_6_DayTime_R5_4.mat 45 | /tests/SSB_files/TME_SSB_6_GridLoad_3.mat 46 | /tests/SSB_files/TME_SSB_6_GridLoad_4.mat 47 | -------------------------------------------------------------------------------- /Readme.rst: -------------------------------------------------------------------------------- 1 | awesim 2 | ====== 3 | 4 | *Optimize your simulation workflow.* 5 | 6 | awesim is written in **Python** and contains tools for pre- and post-processing of **Modelica** models. 7 | 8 | With awesim you can: 9 | 10 | 1. compile models, set parameters and solver options and start simulations 11 | 2. run simulations in parallel on the same computer or different machines 12 | 3. open result files, access simulation parameters and trajectories, make plots 13 | 4. keep an overview of your cases by creating an index (called simdex) of different results 14 | 5. filter your results based on filenames or parameter sets 15 | 16 | Most of the tools provided are currently based on Dymola and the .mat result file. However, as other tools support this format, **awesim** could as well be used with OpenModelica or JModelica or other tools. 17 | 18 | Simulation management is currently developed by 3E and KU Leuven (Belgium). We are currently evaluating the license... 19 | 20 | See the documentation for more information. 21 | 22 | -------------------------------------------------------------------------------- /Readme.rst~: -------------------------------------------------------------------------------- 1 | awesim 2 | ====== 3 | 4 | *Optimize your simulation workflow.* 5 | 6 | awesim is written in **Python** and contains tools for pre- and post-processing of **Modelica** models. 7 | 8 | With awesim you can: 9 | 10 | 1. compile models, set parameters and solver options and start simulations 11 | 2. run simulations in parallel on the same computer or different machines 12 | 3. open result files, access simulation parameters and trajectories, make plots 13 | 4. keep an overview of your cases by creating an index (called simdex) of different results 14 | 5. filter your results based on filenames or parameter sets 15 | 16 | Most of the tools provided are currently based on Dymola and the .mat result file. 17 | 18 | Simulation management is currently developed by 3E and KU Leuven (Belgium). We are currently evaluating the license... 19 | 20 | See the documentation for more information. 21 | 22 | -------------------------------------------------------------------------------- /awesim/__init__.py: -------------------------------------------------------------------------------- 1 | from simulation import Simulation 2 | from simdex import Simdex, load_simdex 3 | from result import Result 4 | from process import Process -------------------------------------------------------------------------------- /awesim/process.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | 5 | @author: Roel De Coninck 6 | """ 7 | #import numpy as np 8 | #import os 9 | #import scipy.io 10 | #import re 11 | import copy 12 | #import matplotlib.pyplot as plt 13 | #from matplotlib.dates import date2num 14 | #import cPickle as pickle 15 | #import bisect 16 | #import tables as tbl 17 | #from datetime import datetime, timedelta 18 | #import pandas 19 | import pdb 20 | 21 | class Process(object): 22 | """ 23 | Class defining pre- and post processing of a simulation 24 | 25 | The variable 'Time' is automatically created 26 | 27 | This documentation needs completion, mainly the __init__() method 28 | 29 | 30 | """ 31 | 32 | def __init__(self, mothers=None, parameters=None, sub_pars=None, variables=None, 33 | sub_vars=None, pp=None, integrate=None): 34 | """Instantiate the Process object 35 | 36 | parameters 37 | ---------- 38 | - mothers: a list of mothers objects, as strings. Arrays are supported 39 | in that case the '[' will be converted into '_' and the ] will be 40 | removed. Example d[1] becomes d_1. In combination with a sub_par 41 | or sub_var, the . will be replaced by a '_'. 42 | So the shortname for d[12].TSto will be d_12_TSto 43 | - parameters: a dictionary with shortname:longname pairs for parameters. 44 | The shortnames can be used in postprocessing formulas (see pp) 45 | - sub_pars: a dictionary with shortname:longname pairs for parameters 46 | that are children of the mothers. 47 | Example: if you have a c1.TInitialValue and a c2.TInitialValue, 48 | you can have mothers = ['c1', c2'] and 49 | sub_vars = {'TStart': 'TInitialValue'} 50 | - variables: analoguous to parameters 51 | - sub_vars: analoguous to sub_pars 52 | - pp: a list of post-processing strings. Each string will be executed 53 | and will generate a new variable that will be stored and that can be 54 | used in following post porcessing strings. If the variable names used 55 | in a pp string are sub_vars or sub_pars, the string will be executed 56 | for each mother. 57 | 58 | It is crucial to surround the names of variables by spaces so they can be 59 | looked up in the parameters and variables dictionaries. 60 | 61 | - integrate: dictionary with variables to be integrated over time. 62 | The dictionary has shortname:scaling pairs, the scaling factor will 63 | be multiplied to the result of np.trapz(shortname, time). The 64 | resulting value will be stored under shortname_Int. If the shortname 65 | is a sub_var, the integration will be done for every mother. 66 | 67 | Example: mothers = ['c1', c2'], sub_vars = {'Q':'Q_flow'}, 68 | integrate = {'Q':1e-6} will create c1_Q_Int and c2_Q_Int. 69 | 70 | """ 71 | #pdb.set_trace() 72 | pp_int = [] 73 | 74 | # make/complete the variables and parameter dicts, full paths 75 | if variables is None: 76 | self.variables = {} 77 | else: 78 | self.variables = copy.copy(variables) 79 | 80 | if parameters is None: 81 | self.parameters = {} 82 | else: 83 | self.parameters = copy.copy(parameters) 84 | 85 | # make sure there are sub_vars and sub_pars, or create empty ones 86 | # otherwise, an exception will be thrown in simulation.postprocess.convert(p) 87 | if sub_vars is None: 88 | self.sub_vars = {} 89 | if sub_pars is None: 90 | self.sub_pars = {} 91 | if mothers is not None: 92 | self.mothers = copy.copy(mothers) 93 | for m in self.mothers: 94 | m_orig = copy.copy(m) 95 | m = m.replace('[', '_') 96 | m = m.replace(']', '') 97 | if sub_vars is not None: 98 | self.sub_vars = copy.copy(sub_vars) 99 | for shortname, longname in self.sub_vars.iteritems(): 100 | self.variables['_'.join([m, shortname])] = '.'.join([m_orig, longname]) 101 | else: 102 | self.sub_vars = {} 103 | if sub_pars is not None: 104 | self.sub_pars = copy.copy(sub_pars) 105 | for shortname, longname in self.sub_pars.iteritems(): 106 | self.parameters['_'.join([m, shortname])] = '.'.join([m_orig, longname]) 107 | else: 108 | self.sub_pars = {} 109 | self.mothers = [m.replace('[', '_') for m in self.mothers] 110 | self.mothers = [m.replace(']', '') for m in self.mothers] 111 | else: 112 | self.mothers = [] 113 | # paramaeters = contains short and long names of the parameters we need. 114 | # The data will be extracted from the .mat files and put in a dictionary 115 | # The short names will be the keys in that dictionary 116 | if self.variables is not {}: 117 | if not self.variables.has_key('Time'): 118 | self.variables['Time'] = 'Time' 119 | 120 | if integrate is not None: 121 | for name, conversion in integrate.iteritems(): 122 | # maka a pp string for this integration action 123 | s = ''.join([name+'_Int', 124 | ' = ', 125 | 'np.trapz( ', 126 | name, 127 | ' , ', 128 | 'Time', 129 | ' ,axis=0)*', 130 | str(conversion), 131 | ' if ', 132 | name, 133 | ' .shape[0]== Time .shape[0] else np.array([0.0])' 134 | ]) 135 | pp_int.append(s) 136 | 137 | # now put the pp_int in front of the self.pp if any 138 | self.pp = [] 139 | self.pp.extend(pp_int) 140 | if pp is not None: 141 | self.pp.extend(pp) 142 | 143 | 144 | 145 | def __str__(self): 146 | """Return a print string""" 147 | 148 | s = '\n'+79*'-'+'\n' 149 | s += 'The content of this Process object is:\n' 150 | s += 'Parameters:' 151 | for shortname,longname in sorted(self.parameters.iteritems()): 152 | s += '\t'.join(['\n', shortname ,'=', longname]) 153 | 154 | s += '\n\nVariables:' 155 | for shortname,longname in sorted(self.variables.iteritems()): 156 | s += '\t'.join(['\n', shortname ,'=', longname]) 157 | 158 | s += '\n\nPost-processing:\n' 159 | if self.pp is not None: 160 | ppprint = '\n'.join(self.pp) 161 | else: 162 | ppprint = '\nNo post-processing defined\n' 163 | s += ppprint 164 | 165 | return s 166 | -------------------------------------------------------------------------------- /awesim/result.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Aug 30 21:36:52 2012 4 | 5 | @author: RDC 6 | """ 7 | 8 | import numpy as np 9 | #import os 10 | #import scipy.io 11 | #import re 12 | import copy 13 | import matplotlib.pyplot as plt 14 | from matplotlib.dates import date2num 15 | #import cPickle as pickle 16 | #import bisect 17 | #import tables as tbl 18 | from datetime import datetime, timedelta 19 | from .utilities import aggregate_by_time, make_datetimeindex, aggregate_dataframe 20 | import pandas as pd 21 | import pdb 22 | import pickle 23 | 24 | 25 | class Result(object): 26 | """ 27 | Class containing the result for one single variable but for different 28 | simulations. An instance from this class is returned from Simdex.get() 29 | 30 | This class also contains the plot functionality and methods to apply 31 | basic operations and functions to it. 32 | """ 33 | 34 | def __init__(self, values, time=None, identifiers=None, **kwargs): 35 | """ 36 | Instantiate a Result object. 37 | 38 | Variables 39 | --------- 40 | 41 | values = dictionary {sid:values} 42 | time (optional) = dictionary {sid:time} 43 | identifiers (optional) = dictionary {sid:identifier} 44 | **kwargs are converted into attributes. This is useful to pass eg. the 45 | year for the data (use for example year=2010) 46 | 47 | """ 48 | 49 | self.val = values 50 | if time is not None: 51 | self.time = time 52 | self.time4plots = {} 53 | if identifiers is not None: 54 | self.identifiers = identifiers 55 | self.simulations = sorted(self.val.keys()) 56 | 57 | for k,v in kwargs.items(): 58 | setattr(self, k, v) 59 | 60 | def save(self, filename): 61 | """ 62 | save(filename) 63 | 64 | Save the Simdex object by pickling it with cPickle 65 | 66 | To unpickle (= load) use the following command: 67 | objectname = pickle.load(open(filename,'rb')) 68 | # 'rb' stands for 'read, binary' 69 | 70 | """ 71 | 72 | f = file(filename,'wb') 73 | # wb stands for 'write, binary' 74 | pickle.dump(self, f) 75 | f.close() 76 | 77 | return filename + ' created' 78 | 79 | def values(self): 80 | """ 81 | Return a list with as elements, the values of the variable in the order 82 | of the sid's 83 | 84 | It does not seem a good idea to return an array by default, cause the 85 | variables for different SID's can have different lengths. 86 | Exception: when the length of each of the variables is 1, a reshaped 87 | array is returned. 88 | 89 | If a value in a single length array is None, it is replaced by NaN in the 90 | returned array. 91 | """ 92 | 93 | result = [self.val[sid] for sid in self.simulations] 94 | 95 | lengths=[] 96 | for i,x in enumerate(result): 97 | try: 98 | l = len(x) 99 | except TypeError: 100 | # x is a value, it is a numpy.float64, so length=1 101 | if x is None: 102 | result[i]=np.NaN 103 | l = 1 104 | lengths.append(l) 105 | 106 | ls = np.array(lengths) 107 | 108 | if np.all(ls==1): 109 | return np.array(result).reshape(len(ls)) 110 | else: 111 | return result 112 | 113 | def trapz(self): 114 | """ 115 | Integrate the values(time) using the composite trapezoidal rule 116 | Returns an array with the integrated values, in sorted order 117 | """ 118 | 119 | if not hasattr(self, 'time'): 120 | raise AttributeError("This Result object has no attribute 'time'") 121 | 122 | result = [] 123 | for sid in self.simulations: 124 | result.append(np.trapz(self.val[sid], x=self.time[sid])) 125 | 126 | return np.array(result) 127 | 128 | 129 | def aggregate(self, period=86400, interval=3600, label='middle'): 130 | """ 131 | Calculate the aggregated average of the timeseries by 132 | period (typical a day) in bins of interval seconds (default = 3600s). 133 | 134 | label = 'left', 'middle' or 'right'. 135 | 'Left' means that the label i contains data from 136 | i till i+1, 'right' means that label i contains data from i-1 till i. 137 | 138 | Returns a dataframe with period/interval values, one for each interval 139 | of the period. 140 | 141 | A few limitations of the method: 142 | - the period has to be a multiple of the interval 143 | - for correct results, the timespan of the timeseries has to be a 144 | multiple of the period 145 | 146 | Example of usefulness: if the timeseries has 15-minute values for 1 year of 147 | eg. the electricity consumption of a building. 148 | - You want to know how a typical daily profile looks like, by 15 minutes 149 | ==> period=86400, interval=900 150 | - you want to know how a typical weekly profile looks like, by hour: 151 | ==> period = 7*86400, interval=3600 152 | 153 | Changelog: 154 | - 20121113: split the method because to_dataframe() does NOT 155 | work with events if there are multiple sid's in the 156 | result. 157 | """ 158 | 159 | # check existence of attributes 160 | if not hasattr(self, 'year'): 161 | print 'We suppose the data is for 2011' 162 | self.year=2011 163 | 164 | #pdb.set_trace() 165 | for i, sid in enumerate(sorted(self.val.keys())): 166 | agg_array = aggregate_by_time(self.val[sid], self.time[sid], period, interval) 167 | if not len(agg_array) == int(period/interval): 168 | raise NotImplementedError("This will not work: there are no values at the interval timestaps for %s" % (sid)) 169 | if i==0: 170 | agg_array_all = copy.deepcopy(agg_array) 171 | else: 172 | agg_array_all = np.column_stack((agg_array_all, agg_array)) 173 | 174 | if label == 'left': 175 | index = make_datetimeindex(np.arange(0, period, interval), self.year) 176 | elif label == 'right': 177 | index = make_datetimeindex(np.arange(interval, period+interval, interval), self.year) 178 | elif label == 'middle': 179 | index = make_datetimeindex(np.arange(0+interval/2., period+interval/2., interval), self.year) 180 | 181 | df_agg = pd.DataFrame(data=agg_array_all, index=index, 182 | columns=sorted(self.val.keys())) 183 | return df_agg 184 | 185 | 186 | 187 | def smooth(self, interval=300): 188 | """ 189 | Calculate the running average of a timeseries 190 | 191 | Parameters 192 | ---------- 193 | interval: interval for the running average, in seconds (default = 300s) 194 | 195 | Returns 196 | ------- 197 | 198 | returns a result object with smoothened values and adapted time 199 | """ 200 | 201 | def smooth_by_time(signal, time, interval=300, label='left'): 202 | """ 203 | Function to calculate the running average of a timeseries 204 | in bins of interval seconds (default = 300s). 205 | 206 | """ 207 | #pdb.set_trace() 208 | ratio = interval/(time[1]-time[0]) 209 | 210 | time = np.arange(0, time[-1]+interval, interval) 211 | 212 | data = np.zeros(len(time)) 213 | data[0] = signal[0] 214 | for i in range(1,len(data)): 215 | data[i]=np.mean(signal[((i-1)*ratio):(i*ratio)]) 216 | 217 | return data, time 218 | 219 | value = {} 220 | time = {} 221 | for sid in self.simulations: 222 | value[sid], time[sid] = smooth_by_time(signal=self.val[sid], time=self.time[sid], interval=interval) 223 | 224 | result = Result(values=value, time=time) 225 | 226 | return result 227 | 228 | 229 | def to_dataframe(self): 230 | """ 231 | Return a pandas dataframe from this result 232 | Attention: this method does NOT work if res contains multiple 233 | SID's who contain events (duplicate index values). 234 | This case is roughly detected by checking the resulting df length. 235 | 236 | """ 237 | # pdb.set_trace() 238 | # check existence of attributes 239 | if not hasattr(self, 'year'): 240 | print 'We suppose the data is for 2011' 241 | self.year=2011 242 | 243 | for i, sid in enumerate(sorted(self.val.keys())): 244 | # create a df from this single 'column' 245 | index = make_datetimeindex(self.time[sid], self.year) 246 | if i==0: 247 | df = pd.DataFrame(data=self.val[sid], index=index, columns=[sid]) 248 | else: 249 | df_right = pd.DataFrame(data=self.val[sid], index=index, columns=[sid]) 250 | df = df.join(df_right, how='outer', sort=True) 251 | 252 | 253 | if len(df) > len(self.val) * max([len(self.val[sid]) for sid in self.val]): 254 | raise NotImplementedError("The result contains multiple SID's and events. Pandas cannot join() these type of dataframes (yet)" ) 255 | return df 256 | 257 | 258 | 259 | 260 | def plot(self, ylabel=None): 261 | """ 262 | Creates a matplotlib figure with a simple plot of the timeseries for 263 | each of the simulations in self.val 264 | 265 | A string can be passed (ylabel) that will be used to label the y-axis 266 | """ 267 | 268 | # In order to plot the timeseries nicely with dates, we use plot_date() 269 | def create_time4plot(sid): 270 | """Convert time into matplotlib format""" 271 | start = datetime(self.year, 1, 1) 272 | datetimes = [start + timedelta(t/86400.) for t in self.time[sid]] 273 | self.time4plots[sid] = date2num(datetimes) 274 | 275 | 276 | 277 | fig = plt.figure() 278 | ax = fig.add_subplot(111) 279 | ax.hold = True 280 | 281 | # we have to make a distinction between plotting timeseries and other results 282 | try: 283 | if len(self.time[self.simulations[0]])==len(self.val[self.simulations[0]]): 284 | plot_type='plot_date' 285 | elif len(self.val[self.simulations[0]]) <> 1: 286 | # most probably an aggregated array. So plot the x values for 287 | # each SID as a series 288 | plot_type='aggregated' 289 | else: 290 | # length == 1, so single_value 291 | plot_type = 'single_value' 292 | except: 293 | try: 294 | if len(self.val[self.simulations[0]]) <> 1: 295 | # most probably an aggregated array. So plot the x values for 296 | # each SID as a series 297 | plot_type='aggregated' 298 | else: 299 | # length == 1, so single_value 300 | plot_type = 'single_value' 301 | except: 302 | # I get an exception when trying to get the length of a single 303 | # intgegrated value 304 | plot_type = 'single_value' 305 | 306 | if plot_type=='plot_date': 307 | for sid in self.simulations: 308 | try: 309 | label = self.identifiers[sid] 310 | except KeyError: 311 | label=sid 312 | if not self.time4plots.has_key(sid): 313 | create_time4plot(sid) 314 | 315 | ax.plot_date(self.time4plots[sid], self.val[sid], fmt='', ls = '-', 316 | label=label) 317 | elif plot_type == 'single_value': 318 | ax.plot(range(len(self.simulations)), self.values(), 'D') 319 | ax.set_xticks(range(len(self.simulations))) 320 | ticklabels = [self.identifiers[sid] for sid in self.simulations] 321 | ax.set_xticklabels(ticklabels) 322 | else: 323 | # aggregated, plot lines with markers 324 | for sid in self.simulations: 325 | try: 326 | label = self.identifiers[sid] 327 | except KeyError: 328 | label=sid 329 | 330 | ax.plot(self.val[sid], 'o-', label=label) 331 | 332 | leg = ax.legend(loc='best') 333 | lines = ax.get_lines() 334 | if plot_type == 'plot_date': 335 | ax.set_xlabel('time') 336 | ax.set_ylabel(ylabel) 337 | plt.grid() 338 | 339 | return [fig, lines, leg] 340 | 341 | 342 | -------------------------------------------------------------------------------- /awesim/utilities.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Utility functions for awesim 5 | 6 | Created 20120911 by RDC 7 | """ 8 | from __future__ import division 9 | import pandas as pd 10 | import numpy as np 11 | from scipy.integrate import cumtrapz 12 | from scipy.stats import spearmanr 13 | import pdb 14 | from copy import deepcopy 15 | import matplotlib.pyplot as plt 16 | from matplotlib.dates import date2num 17 | from datetime import datetime, timedelta 18 | 19 | def make_datetimeindex(array_in_seconds, year): 20 | """ 21 | Create a pandas DateIndex from a time vector in seconds and the year. 22 | """ 23 | 24 | start = pd.datetime(year, 1, 1) 25 | datetimes = [start + pd.datetools.timedelta(t/86400.) for t in array_in_seconds] 26 | 27 | return pd.DatetimeIndex(datetimes) 28 | 29 | 30 | def aggregate_by_time(signal, time, period=86400, interval=900, year=2012): 31 | """ 32 | Function to calculate the aggregated average of a timeseries by 33 | period (typical a day) in bins of interval seconds (default = 900s). 34 | 35 | 36 | Returns an array with period/interval values, one for each interval 37 | of the period. 38 | 39 | Limitations of the method: 40 | - the period has to be a multiple of the interval 41 | 42 | This function can be used in the post-processing too. 43 | """ 44 | 45 | 46 | dr = make_datetimeindex(time, year) 47 | df = pd.DataFrame(data=signal, index=dr, columns=['signal']) 48 | 49 | return aggregate_dataframe(df, period, interval, label='left').values 50 | 51 | 52 | def aggregate_dataframe(dataframe, period=86400, interval=3600, label='middle'): 53 | """ 54 | Function to calculate the aggregated average of a timeseries by 55 | period (typical a day) in bins of interval seconds (default = 3600s). 56 | 57 | label = 'left', 'middle' or 'right'. 58 | 'Left' means that the label i contains data from 59 | i till i+1, 'right' means that label i contains data from i-1 till i. 60 | 61 | Returns a new dataframe with period/interval values, one for each interval 62 | of the period. 63 | 64 | A few limitations of the method: 65 | - the period has to be a multiple of the interval 66 | - for correct results, the timespan of the timeseries has to be a 67 | multiple of the period 68 | 69 | Example of usefulness: if the timeseries has 15-minute values for 1 year of 70 | eg. the electricity consumption of a building. 71 | - You want to know how a typical daily profile looks like, by 15 minutes 72 | ==> period=86400, interval=900 73 | - you want to know how a typical weekly profile looks like, by hour: 74 | ==> period = 7*86400, interval=3600 75 | 76 | """ 77 | #pdb.set_trace() 78 | # first, create cumulative integrated signals for every column, put these 79 | # in a new dataframe called cum 80 | 81 | if np.round(np.remainder(period, interval), 7) != 0: 82 | raise ValueError('Aggregation will lead to wrong results if period is no multiple of interval') 83 | 84 | # There's a problem with the join() operation on dataframes with duplicate 85 | # time index. The current method returns a cartesian product instead of 86 | # what we want. We circumvent by joining the aggregated values 87 | 88 | 89 | for i, c in enumerate(dataframe.columns): 90 | # we need to remove the empty values for the cumtrapz function to work 91 | 92 | ts = dataframe[c].dropna() 93 | #cumdata misses one value. We add a zero in front. 94 | cumdata = np.zeros(len(ts.values)) 95 | cumdata[1:] = cumtrapz(ts.values, ts.index.asi8/1e9) 96 | tscum = pd.DataFrame(data=cumdata, 97 | index=ts.index, 98 | columns=[c]) 99 | 100 | # then, resample the dataframe by the given interval 101 | # We convert it to milliseconds in order to obtain integer values for most cases 102 | interval_string = str(int(interval*1000)) + 'L' 103 | ts_resampled = tscum.resample(interval_string, how='last', 104 | closed='right', label='right') 105 | if i==0: 106 | # first run, result is the ts 107 | df_resampled = deepcopy(ts_resampled) 108 | else: 109 | df_resampled.join(ts_resampled) 110 | 111 | # create dataframe with the average signal during each interval 112 | df_diff = pd.DataFrame(index=df_resampled.index[:-1]) 113 | for c in df_resampled.columns: 114 | 115 | reshaped_array = df_resampled[c].values.reshape(len(df_resampled)) 116 | diffdata = np.diff(reshaped_array)/interval 117 | df_diff[c] = diffdata 118 | 119 | 120 | 121 | # now create bins for the groupby() method 122 | # time in seconds 123 | time_s = df_diff.index.asi8/1e9 124 | time_s -= time_s[0] 125 | try: 126 | df_diff['bins'] = np.mod(time_s, period) 127 | except(KeyError): 128 | df_diff = pd.DataFrame(df_resampled) 129 | df_diff['bins'] = np.mod(time_s, period) 130 | 131 | 132 | df_aggr = df_diff.groupby('bins').mean() 133 | 134 | # pdb.set_trace() 135 | # replace the bins by a real datetime index 136 | if label == 'left': 137 | df_aggr.index = df_diff.index[:len(df_aggr)] 138 | elif label == 'right': 139 | df_aggr.index = df_diff.index[1:1+len(df_aggr)] 140 | elif label == 'middle': 141 | df_aggr.index = df_diff.index[:len(df_aggr)] 142 | df_aggr = df_aggr.tshift(int(interval*500), 'L' ) 143 | 144 | return df_aggr 145 | 146 | 147 | def analyse_cputime_single(cputime, time, var, cumulative=False, interval=900, plot=True): 148 | """Analyse the relation between cputime and a trajectory. 149 | 150 | It is required that the time array contains an entry for every multiple of 151 | the interval. 152 | 153 | Parameters: 154 | ----------- 155 | * cputime: array with (trajectory of the) cputime (cumulative) 156 | * time: simulation time (array in seconds, can contain events) 157 | * var: variable for which the correlation is to be found 158 | * cumulative: if True, the variable is a cumulative (integrated) one 159 | * interval: the desired interval for resampling, integer in seconds 160 | * plot: if True, a time plot will be made 161 | 162 | Output: 163 | ------- 164 | Correlation coefficient as float, a screen dump and plot 165 | """ 166 | 167 | if not cumulative: 168 | var_cum = cumtrapz(var, time) 169 | else: 170 | var_cum = var 171 | 172 | x = np.arange(time[0], time[-1], interval) 173 | index = np.searchsorted(time, x) 174 | cpu_smpl = cputime[index] 175 | var_smpl = var_cum[index] 176 | 177 | cpu_diff = np.diff(cpu_smpl) 178 | var_diff = np.diff(var_smpl) 179 | 180 | corr = spearmanr(var_diff, cpu_diff)[0] 181 | 182 | print 'The correlation is %g' % (corr) 183 | 184 | if plot: 185 | start = datetime(2011, 1, 1) 186 | datetimes = [start + timedelta(t/86400.) for t in x] 187 | time4plots = date2num(datetimes) 188 | plt.figure() 189 | plt.plot_date(time4plots[:-1], cpu_diff/cpu_diff.max(), 'r', label='cpu-time') 190 | plt.plot_date(time4plots[:-1], var_diff/var_diff.max(), 'b', label='variable') 191 | plt.legend(loc='best') 192 | 193 | return corr 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/GreyBoxBuildings.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/GreyBoxBuildings.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/GreyBoxBuildings" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/GreyBoxBuildings" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /doc/Simulation_demo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "Simulation_demo" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "code", 12 | "collapsed": false, 13 | "input": [ 14 | "a=range(10)" 15 | ], 16 | "language": "python", 17 | "metadata": {}, 18 | "outputs": [], 19 | "prompt_number": 1 20 | }, 21 | { 22 | "cell_type": "code", 23 | "collapsed": false, 24 | "input": [ 25 | "a" 26 | ], 27 | "language": "python", 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "output_type": "pyout", 32 | "prompt_number": 2, 33 | "text": [ 34 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" 35 | ] 36 | } 37 | ], 38 | "prompt_number": 2 39 | }, 40 | { 41 | "cell_type": "code", 42 | "collapsed": false, 43 | "input": [ 44 | "from simman.simman import Simulation" 45 | ], 46 | "language": "python", 47 | "metadata": {}, 48 | "outputs": [], 49 | "prompt_number": 3 50 | }, 51 | { 52 | "cell_type": "code", 53 | "collapsed": false, 54 | "input": [ 55 | "import os, sys\n", 56 | "os.getcwd()" 57 | ], 58 | "language": "python", 59 | "metadata": {}, 60 | "outputs": [ 61 | { 62 | "output_type": "pyout", 63 | "prompt_number": 4, 64 | "text": [ 65 | "'C:\\\\Workspace\\\\Python\\\\SimulationManagement\\\\doc'" 66 | ] 67 | } 68 | ], 69 | "prompt_number": 4 70 | }, 71 | { 72 | "cell_type": "code", 73 | "collapsed": false, 74 | "input": [ 75 | "cd ../tests" 76 | ], 77 | "language": "python", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "output_type": "stream", 82 | "stream": "stdout", 83 | "text": [ 84 | "C:\\Workspace\\Python\\SimulationManagement\\tests\n" 85 | ] 86 | } 87 | ], 88 | "prompt_number": 6 89 | }, 90 | { 91 | "cell_type": "code", 92 | "collapsed": false, 93 | "input": [ 94 | "sim=Simulation('LinkedCapacities.mat')" 95 | ], 96 | "language": "python", 97 | "metadata": {}, 98 | "outputs": [], 99 | "prompt_number": 7 100 | }, 101 | { 102 | "cell_type": "code", 103 | "collapsed": false, 104 | "input": [ 105 | "sim.names" 106 | ], 107 | "language": "python", 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "output_type": "pyout", 112 | "prompt_number": 9, 113 | "text": [ 114 | "[u'Time',\n", 115 | " u'c1.heatPort.T',\n", 116 | " u'c1.heatPort.Q_flow',\n", 117 | " u'c1.C',\n", 118 | " u'c1.T',\n", 119 | " u'c1.der(T)',\n", 120 | " u'c2.heatPort.T',\n", 121 | " u'c2.heatPort.Q_flow',\n", 122 | " u'c2.C',\n", 123 | " u'c2.T',\n", 124 | " u'c2.der(T)',\n", 125 | " u'r.heatPort_a.T',\n", 126 | " u'r.heatPort_a.Q_flow',\n", 127 | " u'r.heatPort_b.T',\n", 128 | " u'r.heatPort_b.Q_flow',\n", 129 | " u'r.R']" 130 | ] 131 | } 132 | ], 133 | "prompt_number": 9 134 | }, 135 | { 136 | "cell_type": "code", 137 | "collapsed": false, 138 | "input": [ 139 | "sim.separate()" 140 | ], 141 | "language": "python", 142 | "metadata": {}, 143 | "outputs": [ 144 | { 145 | "output_type": "pyout", 146 | "prompt_number": 10, 147 | "text": [ 148 | "True" 149 | ] 150 | } 151 | ], 152 | "prompt_number": 10 153 | }, 154 | { 155 | "cell_type": "code", 156 | "collapsed": false, 157 | "input": [ 158 | "sim.parameters" 159 | ], 160 | "language": "python", 161 | "metadata": {}, 162 | "outputs": [ 163 | { 164 | "output_type": "pyout", 165 | "prompt_number": 11, 166 | "text": [ 167 | "[u'c1.C', u'c2.C', u'r.R']" 168 | ] 169 | } 170 | ], 171 | "prompt_number": 11 172 | }, 173 | { 174 | "cell_type": "code", 175 | "collapsed": false, 176 | "input": [ 177 | "sim.get_value('c1.T')" 178 | ], 179 | "language": "python", 180 | "metadata": {}, 181 | "outputs": [ 182 | { 183 | "output_type": "pyout", 184 | "prompt_number": 13, 185 | "text": [ 186 | "array([ 400. , 394.90524292, 390.63452148, 387.06240845,\n", 187 | " 384.08087158, 381.5881958 , 379.50305176, 377.75805664,\n", 188 | " 376.29608154, 375.07043457, 374.04342651, 373.1831665 ,\n", 189 | " 372.46203613, 371.85726929, 371.35040283, 370.92440796,\n", 190 | " 370.5663147 , 370.26568604, 370.01528931, 369.80883789,\n", 191 | " 369.63793945, 369.49505615, 369.37789917, 369.27865601,\n", 192 | " 369.19534302, 369.12600708, 369.0663147 , 369.01712036,\n", 193 | " 368.974823 , 368.93948364, 368.90960693, 368.88418579,\n", 194 | " 368.86300659, 368.84487915, 368.82965088, 368.81677246,\n", 195 | " 368.80578613, 368.79638672, 368.78833008, 368.78152466,\n", 196 | " 368.77590942, 368.77084351, 368.76651001, 368.76287842,\n", 197 | " 368.76000977, 368.7578125 , 368.75567627, 368.75393677,\n", 198 | " 368.75262451, 368.7517395 , 368.7512207 ], dtype=float32)" 199 | ] 200 | } 201 | ], 202 | "prompt_number": 13 203 | }, 204 | { 205 | "cell_type": "code", 206 | "collapsed": false, 207 | "input": [ 208 | "sim.exist('flow')" 209 | ], 210 | "language": "python", 211 | "metadata": {}, 212 | "outputs": [ 213 | { 214 | "output_type": "pyout", 215 | "prompt_number": 14, 216 | "text": [ 217 | "[u'c1.heatPort.Q_flow',\n", 218 | " u'c2.heatPort.Q_flow',\n", 219 | " u'r.heatPort_a.Q_flow',\n", 220 | " u'r.heatPort_b.Q_flow']" 221 | ] 222 | } 223 | ], 224 | "prompt_number": 14 225 | }, 226 | { 227 | "cell_type": "code", 228 | "collapsed": false, 229 | "input": [ 230 | "sim.get_value(_[0])" 231 | ], 232 | "language": "python", 233 | "metadata": {}, 234 | "outputs": [ 235 | { 236 | "output_type": "pyout", 237 | "prompt_number": 15, 238 | "text": [ 239 | "array([-16.66666603, -13.94945908, -11.67174625, -9.76662064,\n", 240 | " -8.17646122, -6.84704447, -5.73496342, -4.80429745,\n", 241 | " -4.02458429, -3.37089443, -2.8231647 , -2.36435223,\n", 242 | " -1.97975922, -1.65721416, -1.38687682, -1.15968394,\n", 243 | " -0.96869361, -0.8083666 , -0.67481321, -0.56471747,\n", 244 | " -0.47356313, -0.39735669, -0.33487868, -0.28195667,\n", 245 | " -0.23752058, -0.20053294, -0.16870825, -0.14247204,\n", 246 | " -0.11990179, -0.10105903, -0.08511797, -0.07156019,\n", 247 | " -0.06026352, -0.05059919, -0.04248295, -0.03560873,\n", 248 | " -0.02975156, -0.0247334 , -0.02044593, -0.01681487,\n", 249 | " -0.01381052, -0.01111626, -0.00880407, -0.00687151,\n", 250 | " -0.0053329 , -0.00416404, -0.00302849, -0.00210657,\n", 251 | " -0.00140184, -0.00093066, -0.00064751], dtype=float32)" 252 | ] 253 | } 254 | ], 255 | "prompt_number": 15 256 | }, 257 | { 258 | "cell_type": "code", 259 | "collapsed": false, 260 | "input": [ 261 | "sim.get_objects('c1.heatPort')" 262 | ], 263 | "language": "python", 264 | "metadata": {}, 265 | "outputs": [ 266 | { 267 | "output_type": "pyout", 268 | "prompt_number": 19, 269 | "text": [ 270 | "[u'T', u'Q_flow']" 271 | ] 272 | } 273 | ], 274 | "prompt_number": 19 275 | }, 276 | { 277 | "cell_type": "code", 278 | "collapsed": false, 279 | "input": [ 280 | "sim.extract({'T':'c1.T'})" 281 | ], 282 | "language": "python", 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "output_type": "pyout", 287 | "prompt_number": 20, 288 | "text": [ 289 | "{'T': array([ 400. , 394.90524292, 390.63452148, 387.06240845,\n", 290 | " 384.08087158, 381.5881958 , 379.50305176, 377.75805664,\n", 291 | " 376.29608154, 375.07043457, 374.04342651, 373.1831665 ,\n", 292 | " 372.46203613, 371.85726929, 371.35040283, 370.92440796,\n", 293 | " 370.5663147 , 370.26568604, 370.01528931, 369.80883789,\n", 294 | " 369.63793945, 369.49505615, 369.37789917, 369.27865601,\n", 295 | " 369.19534302, 369.12600708, 369.0663147 , 369.01712036,\n", 296 | " 368.974823 , 368.93948364, 368.90960693, 368.88418579,\n", 297 | " 368.86300659, 368.84487915, 368.82965088, 368.81677246,\n", 298 | " 368.80578613, 368.79638672, 368.78833008, 368.78152466,\n", 299 | " 368.77590942, 368.77084351, 368.76651001, 368.76287842,\n", 300 | " 368.76000977, 368.7578125 , 368.75567627, 368.75393677,\n", 301 | " 368.75262451, 368.7517395 , 368.7512207 ], dtype=float32)}" 302 | ] 303 | } 304 | ], 305 | "prompt_number": 20 306 | }, 307 | { 308 | "cell_type": "code", 309 | "collapsed": false, 310 | "input": [], 311 | "language": "python", 312 | "metadata": {}, 313 | "outputs": [] 314 | } 315 | ], 316 | "metadata": {} 317 | } 318 | ] 319 | } -------------------------------------------------------------------------------- /doc/build/doctrees/class_overview.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/doctrees/class_overview.doctree -------------------------------------------------------------------------------- /doc/build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/doctrees/environment.pickle -------------------------------------------------------------------------------- /doc/build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/doctrees/index.doctree -------------------------------------------------------------------------------- /doc/build/doctrees/process.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/doctrees/process.doctree -------------------------------------------------------------------------------- /doc/build/doctrees/simulation.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/doctrees/simulation.doctree -------------------------------------------------------------------------------- /doc/build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 39c6fcc3ba0710c60dc040f3b6dbd898 4 | tags: fbb0d17656682115ca4d033fb2f83ba1 5 | -------------------------------------------------------------------------------- /doc/build/html/_modules/awesim.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | awesim — awesim 0.1 documentation 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 42 | 43 |
44 |
45 |
46 |
47 | 48 |

Source code for awesim

49 | from simulation import Simulation
50 | from simdex import Simdex, load_simdex
51 | from result import Result
52 | from process import Process
53 | 
54 | 55 |
56 |
57 |
58 |
59 |
60 | 72 | 73 |
74 |
75 |
76 |
77 | 87 | 91 | 92 | -------------------------------------------------------------------------------- /doc/build/html/_modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Overview: module code — awesim 0.1 documentation 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 40 | 41 |
42 |
43 |
44 |
45 | 46 |

All modules for which code is available

47 | 49 | 50 |
51 |
52 |
53 |
54 |
55 | 67 | 68 |
69 |
70 |
71 |
72 | 81 | 85 | 86 | -------------------------------------------------------------------------------- /doc/build/html/_sources/class_overview.txt: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _class_overview: 3 | 4 | Class overview 5 | ============== 6 | 7 | Class Simulation 8 | **************** 9 | .. autoclass:: awesim.Simulation 10 | :members: 11 | :private-members: 12 | :special-members: 13 | 14 | Class Process 15 | **************** 16 | .. autoclass:: awesim.Process 17 | :members: 18 | :private-members: 19 | :special-members: 20 | 21 | Class Simdex 22 | **************** 23 | .. autoclass:: awesim.Simdex 24 | :members: 25 | :private-members: 26 | :special-members: 27 | 28 | Class Result 29 | **************** 30 | .. autoclass:: awesim.Result 31 | :members: 32 | :private-members: 33 | :special-members: 34 | -------------------------------------------------------------------------------- /doc/build/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | .. awesim documentation master file, created by 2 | sphinx-quickstart on Wed Aug 29 15:35:15 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | awesim 7 | ====== 8 | 9 | *Optimize your simulation workflow.* 10 | 11 | awesim is written in **Python** and contains tools for pre- and post-processing of **Modelica** models. 12 | 13 | With awesim you can: 14 | 15 | 1. compile models, set parameters and solver options and start simulations 16 | 2. run simulations in parallel on the same computer or different machines 17 | 3. open result files, access simulation parameters and trajectories, make plots 18 | 4. keep an overview of your cases by creating an index (called simdex) of different results 19 | 5. filter your results based on filenames or parameter sets 20 | 21 | Most of the tools provided are currently based on Dymola and the .mat result file. 22 | 23 | awesim is licensed under the xxx license. 24 | 25 | 26 | Contents 27 | ======== 28 | 29 | 30 | .. toctree:: 31 | :maxdepth: 2 32 | 33 | simulation 34 | process 35 | simdex 36 | result 37 | class_overview 38 | 39 | 40 | 41 | 42 | Indices and tables 43 | ================== 44 | 45 | * :ref:`genindex` 46 | * :ref:`modindex` 47 | * :ref:`search` 48 | 49 | -------------------------------------------------------------------------------- /doc/build/html/_sources/process.txt: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _process: 3 | 4 | Defining a post-process 5 | ======================= 6 | 7 | Post-processing is the data treatment that is unavoidable after running your simulations. There are different things to get done: 8 | 9 | * extract all useful information from the simulation file(s) 10 | * treat the results: number crunching like scaling, integration, aggregation, or simple arithmetic operations 11 | * compare results of different runs with plots, tables, etc. 12 | * store your results for later use 13 | 14 | Post processing is often a time-intensive step in the simulation set-up. To ease often used post-processing operations, awsim defines a Process class. A Process is a set of operations that can be executed on a Simulation instance. Let's start with a simple example. 15 | 16 | .. ipython:: python 17 | :suppress: 18 | 19 | import os 20 | print os.getcwd() 21 | os.chdir('../tests') 22 | print os.getcwd() 23 | 24 | .. ipython:: python 25 | 26 | import numpy as np 27 | from awesim import Simulation, Process 28 | 29 | .. ipython:: python 30 | :suppress: 31 | 32 | np.set_printoptions(precision=2, suppress=True) 33 | 34 | .. ipython:: python 35 | 36 | process = Process(variables={'T': 'c1.T'}) 37 | print process 38 | 39 | This process has a dictionary ``variables`` that contains a mapping of short to full variable names. You'll notice that the variable 'Time' is automatically added to the variables. When we apply this simple process to a Simulation, the result will be the same as invoking ``simulation.extract(process.variables)`` 40 | 41 | .. ipython:: python 42 | 43 | sim = Simulation('LinkedCapacities') 44 | sim.postprocess(process) 45 | 46 | If we need parameter values in the postprocessing, we can add (or edit) the attribute ``parameters``. 47 | 48 | .. ipython:: python 49 | 50 | process.parameters = {'c1': 'c1.C', 'c2': 'c2.C'} 51 | print process 52 | 53 | One of the main uses of the process class is the definition of post-processing actions. These are defined as strings. A simple example could be the conversion of the temperature of capacity c1 from Kelvin to degree Celsius. 54 | 55 | .. ipython:: python 56 | 57 | post_proc_string = 'T_degC = T - 273.15' 58 | process.pp.append(post_proc_string) 59 | sim.postprocess(process) 60 | 61 | You'll notice that we have created a new variable, T_degC which is added to the result of the post-processing. Note that in the post-processing string, we were able to use the shortname 'T' that was introduced as key in the ``variables`` of the process. 62 | -------------------------------------------------------------------------------- /doc/build/html/_sources/simulation.txt: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _simulation: 3 | 4 | Working with single simulations 5 | =============================== 6 | 7 | To get started, we'll always use the following import statements 8 | 9 | .. ipython:: python 10 | :suppress: 11 | 12 | import os 13 | print os.getcwd() 14 | os.chdir('../tests') 15 | print os.getcwd() 16 | 17 | .. ipython:: python 18 | 19 | import numpy as np 20 | from awesim import Simulation 21 | 22 | .. ipython:: python 23 | :suppress: 24 | 25 | np.set_printoptions(precision=2, suppress=True) 26 | 27 | Suppose we have a simulation result file called 'LinkedCapacities.mat'. 28 | We can instantiate a :class:'~awesim.Simulation' object from this file. 29 | 30 | .. ipython:: python 31 | 32 | sim = Simulation('LinkedCapacities') #with our without .mat extension 33 | print sim 34 | 35 | When instantiating a Simulation object, the .mat file is read in memory. 36 | The filename is stored as an attribute. 37 | 38 | .. ipython:: python 39 | 40 | sim.filename 41 | 42 | A simulation object can be introspected in different ways. A list of all 43 | known parameters and variables can be obtained. For large simulations, the method ``get_objects()`` will be more practical. It lists all the sub-objects from a given parent. The simulation root will be taken if no parent is given. 44 | .. ipython:: python 45 | 46 | sim.names 47 | sim.get_objects() 48 | sim.get_objects('C1') 49 | 50 | The list of known names can be split in parameters and variables with the method ``separate()``. 51 | This will create three attributes: 52 | 53 | 1. ``Simulation.variables`` 54 | 2. ``Simulation.parameters`` 55 | 3. ``Simulation.parametervalues`` 56 | 57 | .. ipython:: python 58 | 59 | sim.separate() 60 | sim.variables 61 | for p,v in zip(sim.parameters, sim.parametervalues): 62 | print p, ' = ', str(v) 63 | 64 | A search method is foreseen: ``Simulation.exist()``. It will return a list of all names that satisfy the search criterium. You can even use regular expressions in your search. 65 | 66 | .. ipython:: python 67 | 68 | sim.exist('q_flow') 69 | 70 | There are two methods to obtain the values. The first one is ``Simulation.get_value()``. This method will return a numpy.float for paramters and a numpy.array for trajectories (variables). 71 | 72 | Note: the simulation time is always accessible through 'Time' 73 | 74 | .. ipython:: python 75 | 76 | time = sim.get_value('Time') 77 | Q = sim.get_value(u'r.heatPort_a.Q_flow') 78 | Q_sum = np.trapz(Q, time) 79 | print "The total energy that flowed through the resistance is %.1f J" %Q_sum 80 | 81 | The second method is ``Simulation.extract()``:: 82 | 83 | def extract(self, var, arrays='sum'): 84 | """ 85 | Return dictionary with values of the variables/parameters to extract. 86 | """ 87 | 88 | extract() takes a dictionary as input argument, and will return a dictionary of the same length with the same keys. The variable or parameter names will be replaced with their values. 89 | 90 | .. ipython:: python 91 | 92 | sim.extract({'c1': 'c1.C', 'T1': 'c1.T', 'Q1':'c1.heatPort.Q_flow'}) 93 | 94 | If you want to extract an array of variables, just replace the index (between the []) by 'x'. 95 | There are three possible options for the processing of arrays: 96 | 97 | #. arrays='each': return each of the arrays 98 | #. arrays='sum': return the sum (default) 99 | #. arrays='mean': return the mean 100 | 101 | Here's an example of a simulation result file that contains arrays. 102 | 103 | .. ipython:: python 104 | 105 | sim = Simulation('Array.mat') 106 | sim.get_objects() 107 | sim.extract({'T_array': 'c[x].T'}, arrays='each') 108 | sim.extract({'T_array': 'c[x].T'}, arrays='mean') 109 | 110 | There is one more method in the Simulation class: ``postprocess()``. This method is related to the Result class, it will be explained in the documentation of Result. 111 | 112 | At this moment, there is no automatic plotting method in Simulation. The reason is that is is more convenient to work with the Simdex class, which has methods for plotting. See the documentation of Simdex. 113 | 114 | -------------------------------------------------------------------------------- /doc/build/html/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/ajax-loader.gif -------------------------------------------------------------------------------- /doc/build/html/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | /* -- relbar ---------------------------------------------------------------- */ 19 | 20 | div.related { 21 | width: 100%; 22 | font-size: 90%; 23 | } 24 | 25 | div.related h3 { 26 | display: none; 27 | } 28 | 29 | div.related ul { 30 | margin: 0; 31 | padding: 0 0 0 10px; 32 | list-style: none; 33 | } 34 | 35 | div.related li { 36 | display: inline; 37 | } 38 | 39 | div.related li.right { 40 | float: right; 41 | margin-right: 5px; 42 | } 43 | 44 | /* -- sidebar --------------------------------------------------------------- */ 45 | 46 | div.sphinxsidebarwrapper { 47 | padding: 10px 5px 0 10px; 48 | } 49 | 50 | div.sphinxsidebar { 51 | float: left; 52 | width: 230px; 53 | margin-left: -100%; 54 | font-size: 90%; 55 | } 56 | 57 | div.sphinxsidebar ul { 58 | list-style: none; 59 | } 60 | 61 | div.sphinxsidebar ul ul, 62 | div.sphinxsidebar ul.want-points { 63 | margin-left: 20px; 64 | list-style: square; 65 | } 66 | 67 | div.sphinxsidebar ul ul { 68 | margin-top: 0; 69 | margin-bottom: 0; 70 | } 71 | 72 | div.sphinxsidebar form { 73 | margin-top: 10px; 74 | } 75 | 76 | div.sphinxsidebar input { 77 | border: 1px solid #98dbcc; 78 | font-family: sans-serif; 79 | font-size: 1em; 80 | } 81 | 82 | div.sphinxsidebar #searchbox input[type="text"] { 83 | width: 170px; 84 | } 85 | 86 | div.sphinxsidebar #searchbox input[type="submit"] { 87 | width: 30px; 88 | } 89 | 90 | img { 91 | border: 0; 92 | } 93 | 94 | /* -- search page ----------------------------------------------------------- */ 95 | 96 | ul.search { 97 | margin: 10px 0 0 20px; 98 | padding: 0; 99 | } 100 | 101 | ul.search li { 102 | padding: 5px 0 5px 20px; 103 | background-image: url(file.png); 104 | background-repeat: no-repeat; 105 | background-position: 0 7px; 106 | } 107 | 108 | ul.search li a { 109 | font-weight: bold; 110 | } 111 | 112 | ul.search li div.context { 113 | color: #888; 114 | margin: 2px 0 0 30px; 115 | text-align: left; 116 | } 117 | 118 | ul.keywordmatches li.goodmatch a { 119 | font-weight: bold; 120 | } 121 | 122 | /* -- index page ------------------------------------------------------------ */ 123 | 124 | table.contentstable { 125 | width: 90%; 126 | } 127 | 128 | table.contentstable p.biglink { 129 | line-height: 150%; 130 | } 131 | 132 | a.biglink { 133 | font-size: 1.3em; 134 | } 135 | 136 | span.linkdescr { 137 | font-style: italic; 138 | padding-top: 5px; 139 | font-size: 90%; 140 | } 141 | 142 | /* -- general index --------------------------------------------------------- */ 143 | 144 | table.indextable { 145 | width: 100%; 146 | } 147 | 148 | table.indextable td { 149 | text-align: left; 150 | vertical-align: top; 151 | } 152 | 153 | table.indextable dl, table.indextable dd { 154 | margin-top: 0; 155 | margin-bottom: 0; 156 | } 157 | 158 | table.indextable tr.pcap { 159 | height: 10px; 160 | } 161 | 162 | table.indextable tr.cap { 163 | margin-top: 10px; 164 | background-color: #f2f2f2; 165 | } 166 | 167 | img.toggler { 168 | margin-right: 3px; 169 | margin-top: 3px; 170 | cursor: pointer; 171 | } 172 | 173 | div.modindex-jumpbox { 174 | border-top: 1px solid #ddd; 175 | border-bottom: 1px solid #ddd; 176 | margin: 1em 0 1em 0; 177 | padding: 0.4em; 178 | } 179 | 180 | div.genindex-jumpbox { 181 | border-top: 1px solid #ddd; 182 | border-bottom: 1px solid #ddd; 183 | margin: 1em 0 1em 0; 184 | padding: 0.4em; 185 | } 186 | 187 | /* -- general body styles --------------------------------------------------- */ 188 | 189 | a.headerlink { 190 | visibility: hidden; 191 | } 192 | 193 | h1:hover > a.headerlink, 194 | h2:hover > a.headerlink, 195 | h3:hover > a.headerlink, 196 | h4:hover > a.headerlink, 197 | h5:hover > a.headerlink, 198 | h6:hover > a.headerlink, 199 | dt:hover > a.headerlink { 200 | visibility: visible; 201 | } 202 | 203 | div.body p.caption { 204 | text-align: inherit; 205 | } 206 | 207 | div.body td { 208 | text-align: left; 209 | } 210 | 211 | .field-list ul { 212 | padding-left: 1em; 213 | } 214 | 215 | .first { 216 | margin-top: 0 !important; 217 | } 218 | 219 | p.rubric { 220 | margin-top: 30px; 221 | font-weight: bold; 222 | } 223 | 224 | img.align-left, .figure.align-left, object.align-left { 225 | clear: left; 226 | float: left; 227 | margin-right: 1em; 228 | } 229 | 230 | img.align-right, .figure.align-right, object.align-right { 231 | clear: right; 232 | float: right; 233 | margin-left: 1em; 234 | } 235 | 236 | img.align-center, .figure.align-center, object.align-center { 237 | display: block; 238 | margin-left: auto; 239 | margin-right: auto; 240 | } 241 | 242 | .align-left { 243 | text-align: left; 244 | } 245 | 246 | .align-center { 247 | text-align: center; 248 | } 249 | 250 | .align-right { 251 | text-align: right; 252 | } 253 | 254 | /* -- sidebars -------------------------------------------------------------- */ 255 | 256 | div.sidebar { 257 | margin: 0 0 0.5em 1em; 258 | border: 1px solid #ddb; 259 | padding: 7px 7px 0 7px; 260 | background-color: #ffe; 261 | width: 40%; 262 | float: right; 263 | } 264 | 265 | p.sidebar-title { 266 | font-weight: bold; 267 | } 268 | 269 | /* -- topics ---------------------------------------------------------------- */ 270 | 271 | div.topic { 272 | border: 1px solid #ccc; 273 | padding: 7px 7px 0 7px; 274 | margin: 10px 0 10px 0; 275 | } 276 | 277 | p.topic-title { 278 | font-size: 1.1em; 279 | font-weight: bold; 280 | margin-top: 10px; 281 | } 282 | 283 | /* -- admonitions ----------------------------------------------------------- */ 284 | 285 | div.admonition { 286 | margin-top: 10px; 287 | margin-bottom: 10px; 288 | padding: 7px; 289 | } 290 | 291 | div.admonition dt { 292 | font-weight: bold; 293 | } 294 | 295 | div.admonition dl { 296 | margin-bottom: 0; 297 | } 298 | 299 | p.admonition-title { 300 | margin: 0px 10px 5px 0px; 301 | font-weight: bold; 302 | } 303 | 304 | div.body p.centered { 305 | text-align: center; 306 | margin-top: 25px; 307 | } 308 | 309 | /* -- tables ---------------------------------------------------------------- */ 310 | 311 | table.docutils { 312 | border: 0; 313 | border-collapse: collapse; 314 | } 315 | 316 | table.docutils td, table.docutils th { 317 | padding: 1px 8px 1px 5px; 318 | border-top: 0; 319 | border-left: 0; 320 | border-right: 0; 321 | border-bottom: 1px solid #aaa; 322 | } 323 | 324 | table.field-list td, table.field-list th { 325 | border: 0 !important; 326 | } 327 | 328 | table.footnote td, table.footnote th { 329 | border: 0 !important; 330 | } 331 | 332 | th { 333 | text-align: left; 334 | padding-right: 5px; 335 | } 336 | 337 | table.citation { 338 | border-left: solid 1px gray; 339 | margin-left: 1px; 340 | } 341 | 342 | table.citation td { 343 | border-bottom: none; 344 | } 345 | 346 | /* -- other body styles ----------------------------------------------------- */ 347 | 348 | ol.arabic { 349 | list-style: decimal; 350 | } 351 | 352 | ol.loweralpha { 353 | list-style: lower-alpha; 354 | } 355 | 356 | ol.upperalpha { 357 | list-style: upper-alpha; 358 | } 359 | 360 | ol.lowerroman { 361 | list-style: lower-roman; 362 | } 363 | 364 | ol.upperroman { 365 | list-style: upper-roman; 366 | } 367 | 368 | dl { 369 | margin-bottom: 15px; 370 | } 371 | 372 | dd p { 373 | margin-top: 0px; 374 | } 375 | 376 | dd ul, dd table { 377 | margin-bottom: 10px; 378 | } 379 | 380 | dd { 381 | margin-top: 3px; 382 | margin-bottom: 10px; 383 | margin-left: 30px; 384 | } 385 | 386 | dt:target, .highlighted { 387 | background-color: #fbe54e; 388 | } 389 | 390 | dl.glossary dt { 391 | font-weight: bold; 392 | font-size: 1.1em; 393 | } 394 | 395 | .field-list ul { 396 | margin: 0; 397 | padding-left: 1em; 398 | } 399 | 400 | .field-list p { 401 | margin: 0; 402 | } 403 | 404 | .refcount { 405 | color: #060; 406 | } 407 | 408 | .optional { 409 | font-size: 1.3em; 410 | } 411 | 412 | .versionmodified { 413 | font-style: italic; 414 | } 415 | 416 | .system-message { 417 | background-color: #fda; 418 | padding: 5px; 419 | border: 3px solid red; 420 | } 421 | 422 | .footnote:target { 423 | background-color: #ffa; 424 | } 425 | 426 | .line-block { 427 | display: block; 428 | margin-top: 1em; 429 | margin-bottom: 1em; 430 | } 431 | 432 | .line-block .line-block { 433 | margin-top: 0; 434 | margin-bottom: 0; 435 | margin-left: 1.5em; 436 | } 437 | 438 | .guilabel, .menuselection { 439 | font-family: sans-serif; 440 | } 441 | 442 | .accelerator { 443 | text-decoration: underline; 444 | } 445 | 446 | .classifier { 447 | font-style: oblique; 448 | } 449 | 450 | abbr, acronym { 451 | border-bottom: dotted 1px; 452 | cursor: help; 453 | } 454 | 455 | /* -- code displays --------------------------------------------------------- */ 456 | 457 | pre { 458 | overflow: auto; 459 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 460 | } 461 | 462 | td.linenos pre { 463 | padding: 5px 0px; 464 | border: 0; 465 | background-color: transparent; 466 | color: #aaa; 467 | } 468 | 469 | table.highlighttable { 470 | margin-left: 0.5em; 471 | } 472 | 473 | table.highlighttable td { 474 | padding: 0 0.5em 0 0.5em; 475 | } 476 | 477 | tt.descname { 478 | background-color: transparent; 479 | font-weight: bold; 480 | font-size: 1.2em; 481 | } 482 | 483 | tt.descclassname { 484 | background-color: transparent; 485 | } 486 | 487 | tt.xref, a tt { 488 | background-color: transparent; 489 | font-weight: bold; 490 | } 491 | 492 | h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { 493 | background-color: transparent; 494 | } 495 | 496 | .viewcode-link { 497 | float: right; 498 | } 499 | 500 | .viewcode-back { 501 | float: right; 502 | font-family: sans-serif; 503 | } 504 | 505 | div.viewcode-block:target { 506 | margin: -1px -10px; 507 | padding: 0 10px; 508 | } 509 | 510 | /* -- math display ---------------------------------------------------------- */ 511 | 512 | img.math { 513 | vertical-align: middle; 514 | } 515 | 516 | div.body div.math p { 517 | text-align: center; 518 | } 519 | 520 | span.eqno { 521 | float: right; 522 | } 523 | 524 | /* -- printout stylesheet --------------------------------------------------- */ 525 | 526 | @media print { 527 | div.document, 528 | div.documentwrapper, 529 | div.bodywrapper { 530 | margin: 0 !important; 531 | width: 100%; 532 | } 533 | 534 | div.sphinxsidebar, 535 | div.related, 536 | div.footer, 537 | #top-link { 538 | display: none; 539 | } 540 | } -------------------------------------------------------------------------------- /doc/build/html/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/comment-bright.png -------------------------------------------------------------------------------- /doc/build/html/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/comment-close.png -------------------------------------------------------------------------------- /doc/build/html/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/comment.png -------------------------------------------------------------------------------- /doc/build/html/_static/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | * default.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- default theme. 6 | * 7 | * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | tt { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning tt { 241 | background: #efc2c2; 242 | } 243 | 244 | .note tt { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } -------------------------------------------------------------------------------- /doc/build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | } 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s == 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * small function to check if an array contains 66 | * a given item. 67 | */ 68 | jQuery.contains = function(arr, item) { 69 | for (var i = 0; i < arr.length; i++) { 70 | if (arr[i] == item) 71 | return true; 72 | } 73 | return false; 74 | }; 75 | 76 | /** 77 | * highlight a given string on a jquery object by wrapping it in 78 | * span elements with the given class name. 79 | */ 80 | jQuery.fn.highlightText = function(text, className) { 81 | function highlight(node) { 82 | if (node.nodeType == 3) { 83 | var val = node.nodeValue; 84 | var pos = val.toLowerCase().indexOf(text); 85 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { 86 | var span = document.createElement("span"); 87 | span.className = className; 88 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 89 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 90 | document.createTextNode(val.substr(pos + text.length)), 91 | node.nextSibling)); 92 | node.nodeValue = val.substr(0, pos); 93 | } 94 | } 95 | else if (!jQuery(node).is("button, select, textarea")) { 96 | jQuery.each(node.childNodes, function() { 97 | highlight(this); 98 | }); 99 | } 100 | } 101 | return this.each(function() { 102 | highlight(this); 103 | }); 104 | }; 105 | 106 | /** 107 | * Small JavaScript module for the documentation. 108 | */ 109 | var Documentation = { 110 | 111 | init : function() { 112 | this.fixFirefoxAnchorBug(); 113 | this.highlightSearchWords(); 114 | this.initIndexTable(); 115 | }, 116 | 117 | /** 118 | * i18n support 119 | */ 120 | TRANSLATIONS : {}, 121 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 122 | LOCALE : 'unknown', 123 | 124 | // gettext and ngettext don't access this so that the functions 125 | // can safely bound to a different name (_ = Documentation.gettext) 126 | gettext : function(string) { 127 | var translated = Documentation.TRANSLATIONS[string]; 128 | if (typeof translated == 'undefined') 129 | return string; 130 | return (typeof translated == 'string') ? translated : translated[0]; 131 | }, 132 | 133 | ngettext : function(singular, plural, n) { 134 | var translated = Documentation.TRANSLATIONS[singular]; 135 | if (typeof translated == 'undefined') 136 | return (n == 1) ? singular : plural; 137 | return translated[Documentation.PLURALEXPR(n)]; 138 | }, 139 | 140 | addTranslations : function(catalog) { 141 | for (var key in catalog.messages) 142 | this.TRANSLATIONS[key] = catalog.messages[key]; 143 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 144 | this.LOCALE = catalog.locale; 145 | }, 146 | 147 | /** 148 | * add context elements like header anchor links 149 | */ 150 | addContextElements : function() { 151 | $('div[id] > :header:first').each(function() { 152 | $('\u00B6'). 153 | attr('href', '#' + this.id). 154 | attr('title', _('Permalink to this headline')). 155 | appendTo(this); 156 | }); 157 | $('dt[id]').each(function() { 158 | $('\u00B6'). 159 | attr('href', '#' + this.id). 160 | attr('title', _('Permalink to this definition')). 161 | appendTo(this); 162 | }); 163 | }, 164 | 165 | /** 166 | * workaround a firefox stupidity 167 | */ 168 | fixFirefoxAnchorBug : function() { 169 | if (document.location.hash && $.browser.mozilla) 170 | window.setTimeout(function() { 171 | document.location.href += ''; 172 | }, 10); 173 | }, 174 | 175 | /** 176 | * highlight the search words provided in the url in the text 177 | */ 178 | highlightSearchWords : function() { 179 | var params = $.getQueryParameters(); 180 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 181 | if (terms.length) { 182 | var body = $('div.body'); 183 | window.setTimeout(function() { 184 | $.each(terms, function() { 185 | body.highlightText(this.toLowerCase(), 'highlighted'); 186 | }); 187 | }, 10); 188 | $('') 190 | .appendTo($('#searchbox')); 191 | } 192 | }, 193 | 194 | /** 195 | * init the domain index toggle buttons 196 | */ 197 | initIndexTable : function() { 198 | var togglers = $('img.toggler').click(function() { 199 | var src = $(this).attr('src'); 200 | var idnum = $(this).attr('id').substr(7); 201 | $('tr.cg-' + idnum).toggle(); 202 | if (src.substr(-9) == 'minus.png') 203 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 204 | else 205 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 206 | }).css('display', ''); 207 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 208 | togglers.click(); 209 | } 210 | }, 211 | 212 | /** 213 | * helper function to hide the search marks again 214 | */ 215 | hideSearchWords : function() { 216 | $('#searchbox .highlight-link').fadeOut(300); 217 | $('span.highlighted').removeClass('highlighted'); 218 | }, 219 | 220 | /** 221 | * make the url absolute 222 | */ 223 | makeURL : function(relativeURL) { 224 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 225 | }, 226 | 227 | /** 228 | * get the current relative url 229 | */ 230 | getCurrentURL : function() { 231 | var path = document.location.pathname; 232 | var parts = path.split(/\//); 233 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 234 | if (this == '..') 235 | parts.pop(); 236 | }); 237 | var url = parts.join('/'); 238 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 239 | } 240 | }; 241 | 242 | // quick alias for translations 243 | _ = Documentation.gettext; 244 | 245 | $(document).ready(function() { 246 | Documentation.init(); 247 | }); 248 | -------------------------------------------------------------------------------- /doc/build/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/down-pressed.png -------------------------------------------------------------------------------- /doc/build/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/down.png -------------------------------------------------------------------------------- /doc/build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/file.png -------------------------------------------------------------------------------- /doc/build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/minus.png -------------------------------------------------------------------------------- /doc/build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/plus.png -------------------------------------------------------------------------------- /doc/build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 8 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 9 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 10 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 12 | .highlight .ge { font-style: italic } /* Generic.Emph */ 13 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 16 | .highlight .go { color: #333333 } /* Generic.Output */ 17 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 18 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 20 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 21 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 22 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 23 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 24 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 25 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 26 | .highlight .kt { color: #902000 } /* Keyword.Type */ 27 | .highlight .m { color: #208050 } /* Literal.Number */ 28 | .highlight .s { color: #4070a0 } /* Literal.String */ 29 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 30 | .highlight .nb { color: #007020 } /* Name.Builtin */ 31 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 32 | .highlight .no { color: #60add5 } /* Name.Constant */ 33 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 34 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 35 | .highlight .ne { color: #007020 } /* Name.Exception */ 36 | .highlight .nf { color: #06287e } /* Name.Function */ 37 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 38 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 39 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 40 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 41 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 44 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 45 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 46 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 47 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 48 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 49 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 50 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 51 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 52 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 53 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 54 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 55 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 56 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 57 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 58 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 59 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 60 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 61 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 62 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /doc/build/html/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | // global elements used by the functions. 26 | // the 'sidebarbutton' element is defined as global after its 27 | // creation, in the add_sidebar_button function 28 | var bodywrapper = $('.bodywrapper'); 29 | var sidebar = $('.sphinxsidebar'); 30 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 31 | 32 | // for some reason, the document has no sidebar; do not run into errors 33 | if (!sidebar.length) return; 34 | 35 | // original margin-left of the bodywrapper and width of the sidebar 36 | // with the sidebar expanded 37 | var bw_margin_expanded = bodywrapper.css('margin-left'); 38 | var ssb_width_expanded = sidebar.width(); 39 | 40 | // margin-left of the bodywrapper and width of the sidebar 41 | // with the sidebar collapsed 42 | var bw_margin_collapsed = '.8em'; 43 | var ssb_width_collapsed = '.8em'; 44 | 45 | // colors used by the current theme 46 | var dark_color = $('.related').css('background-color'); 47 | var light_color = $('.document').css('background-color'); 48 | 49 | function sidebar_is_collapsed() { 50 | return sidebarwrapper.is(':not(:visible)'); 51 | } 52 | 53 | function toggle_sidebar() { 54 | if (sidebar_is_collapsed()) 55 | expand_sidebar(); 56 | else 57 | collapse_sidebar(); 58 | } 59 | 60 | function collapse_sidebar() { 61 | sidebarwrapper.hide(); 62 | sidebar.css('width', ssb_width_collapsed); 63 | bodywrapper.css('margin-left', bw_margin_collapsed); 64 | sidebarbutton.css({ 65 | 'margin-left': '0', 66 | 'height': bodywrapper.height() 67 | }); 68 | sidebarbutton.find('span').text('»'); 69 | sidebarbutton.attr('title', _('Expand sidebar')); 70 | document.cookie = 'sidebar=collapsed'; 71 | } 72 | 73 | function expand_sidebar() { 74 | bodywrapper.css('margin-left', bw_margin_expanded); 75 | sidebar.css('width', ssb_width_expanded); 76 | sidebarwrapper.show(); 77 | sidebarbutton.css({ 78 | 'margin-left': ssb_width_expanded-12, 79 | 'height': bodywrapper.height() 80 | }); 81 | sidebarbutton.find('span').text('«'); 82 | sidebarbutton.attr('title', _('Collapse sidebar')); 83 | document.cookie = 'sidebar=expanded'; 84 | } 85 | 86 | function add_sidebar_button() { 87 | sidebarwrapper.css({ 88 | 'float': 'left', 89 | 'margin-right': '0', 90 | 'width': ssb_width_expanded - 28 91 | }); 92 | // create the button 93 | sidebar.append( 94 | '
«
' 95 | ); 96 | var sidebarbutton = $('#sidebarbutton'); 97 | light_color = sidebarbutton.css('background-color'); 98 | // find the height of the viewport to center the '<<' in the page 99 | var viewport_height; 100 | if (window.innerHeight) 101 | viewport_height = window.innerHeight; 102 | else 103 | viewport_height = $(window).height(); 104 | sidebarbutton.find('span').css({ 105 | 'display': 'block', 106 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 107 | }); 108 | 109 | sidebarbutton.click(toggle_sidebar); 110 | sidebarbutton.attr('title', _('Collapse sidebar')); 111 | sidebarbutton.css({ 112 | 'color': '#FFFFFF', 113 | 'border-left': '1px solid ' + dark_color, 114 | 'font-size': '1.2em', 115 | 'cursor': 'pointer', 116 | 'height': bodywrapper.height(), 117 | 'padding-top': '1px', 118 | 'margin-left': ssb_width_expanded - 12 119 | }); 120 | 121 | sidebarbutton.hover( 122 | function () { 123 | $(this).css('background-color', dark_color); 124 | }, 125 | function () { 126 | $(this).css('background-color', light_color); 127 | } 128 | ); 129 | } 130 | 131 | function set_position_from_cookie() { 132 | if (!document.cookie) 133 | return; 134 | var items = document.cookie.split(';'); 135 | for(var k=0; k=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;gf?1:0}),"value")};b.sortedIndex=function(a,c,d){d=d||b.identity;for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.zip=function(){for(var a=b.toArray(arguments),c=b.max(b.pluck(a,"length")),d=new Array(c),e=0;e0?f-c:c-f)>=0)return e;e[g++]=f}};b.bind=function(a,c){var d=b.rest(arguments,2);return function(){return a.apply(c||j,d.concat(b.toArray(arguments)))}};b.bindAll=function(a){var c=b.rest(arguments);if(c.length==0)c=b.functions(a);b.each(c,function(d){a[d]=b.bind(a[d],a)}); 17 | return a};b.delay=function(a,c){var d=b.rest(arguments,2);return setTimeout(function(){return a.apply(a,d)},c)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(b.rest(arguments)))};b.wrap=function(a,c){return function(){var d=[a].concat(b.toArray(arguments));return c.apply(c,d)}};b.compose=function(){var a=b.toArray(arguments);return function(){for(var c=b.toArray(arguments),d=a.length-1;d>=0;d--)c=[a[d].apply(this,c)];return c[0]}};b.keys=function(a){if(b.isArray(a))return b.range(0,a.length); 18 | var c=[];for(var d in a)q.call(a,d)&&c.push(d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=function(a){return b.select(b.keys(a),function(c){return b.isFunction(a[c])}).sort()};b.extend=function(a,c){for(var d in c)a[d]=c[d];return a};b.clone=function(a){if(b.isArray(a))return a.slice(0);return b.extend({},a)};b.tap=function(a,c){c(a);return a};b.isEqual=function(a,c){if(a===c)return true;var d=typeof a;if(d!=typeof c)return false;if(a==c)return true;if(!a&&c||a&&!c)return false; 19 | if(a.isEqual)return a.isEqual(c);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return true;if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return false;if(a.length&&a.length!==c.length)return false;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return false;for(var f in a)if(!b.isEqual(a[f],c[f]))return false;return true};b.isEmpty=function(a){return b.keys(a).length== 20 | 0};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=function(a){return!!(a&&a.concat&&a.unshift)};b.isArguments=function(a){return a&&b.isNumber(a.length)&&!b.isArray(a)&&!r.call(a,"length")};b.isFunction=function(a){return!!(a&&a.constructor&&a.call&&a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return p.call(a)==="[object Number]"};b.isDate=function(a){return!!(a&&a.getTimezoneOffset&&a.setUTCFullYear)};b.isRegExp=function(a){return!!(a&& 21 | a.test&&a.exec&&(a.ignoreCase||a.ignoreCase===false))};b.isNaN=function(a){return b.isNumber(a)&&isNaN(a)};b.isNull=function(a){return a===null};b.isUndefined=function(a){return typeof a=="undefined"};b.noConflict=function(){j._=n;return this};b.identity=function(a){return a};b.breakLoop=function(){throw m;};var s=0;b.uniqueId=function(a){var c=s++;return a?a+c:c};b.template=function(a,c){a=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g, 22 | " ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){var d=b.toArray(arguments); 23 | o.call(d,this._wrapped);return l(c.apply(b,d),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})(); 24 | -------------------------------------------------------------------------------- /doc/build/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/up-pressed.png -------------------------------------------------------------------------------- /doc/build/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/_static/up.png -------------------------------------------------------------------------------- /doc/build/html/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Index — awesim 0.1 documentation 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 42 | 43 |
44 |
45 |
46 |
47 | 48 | 49 |

Index

50 | 51 |
52 | _ 53 | | A 54 | | C 55 | | E 56 | | F 57 | | G 58 | | I 59 | | O 60 | | P 61 | | R 62 | | S 63 | | T 64 | | V 65 | 66 |
67 |

_

68 | 69 | 113 | 131 |
70 | 71 |
__init__() (awesim.Process method) 72 |
73 | 74 |
75 | 76 |
(awesim.Result method) 77 |
78 | 79 | 80 |
(awesim.Simdex method) 81 |
82 | 83 | 84 |
(awesim.Simulation method) 85 |
86 | 87 |
88 | 89 |
__str__() (awesim.Process method) 90 |
91 | 92 |
93 | 94 |
(awesim.Simdex method) 95 |
96 | 97 |
98 | 99 |
__weakref__ (awesim.Process attribute) 100 |
101 | 102 |
103 | 104 |
(awesim.Result attribute) 105 |
106 | 107 |
108 | 109 |
_gen_key() (awesim.Simdex method) 110 |
111 | 112 |
114 | 115 |
_get_par() (awesim.Simdex method) 116 |
117 | 118 | 119 |
_get_var_h5() (awesim.Simdex method) 120 |
121 | 122 | 123 |
_last_key() (awesim.Simdex method) 124 |
125 | 126 | 127 |
_Simdex__get_files() (awesim.Simdex method) 128 |
129 | 130 |
132 | 133 |

A

134 | 135 | 145 | 151 |
136 | 137 |
aggregate() (awesim.Result method) 138 |
139 | 140 | 141 |
analyse_cputime() (awesim.Simulation method) 142 |
143 | 144 |
146 | 147 |
apply() (awesim.Simdex method) 148 |
149 | 150 |
152 | 153 |

C

154 | 155 | 161 |
156 | 157 |
cleanup() (awesim.Simdex method) 158 |
159 | 160 |
162 | 163 |

E

164 | 165 | 177 | 183 |
166 | 167 |
exist() (awesim.Simdex method) 168 |
169 | 170 |
171 | 172 |
(awesim.Simulation method) 173 |
174 | 175 |
176 |
178 | 179 |
extract() (awesim.Simulation method) 180 |
181 | 182 |
184 | 185 |

F

186 | 187 | 197 | 207 |
188 | 189 |
filter() (awesim.Simdex method) 190 |
191 | 192 | 193 |
filter_remove() (awesim.Simdex method) 194 |
195 | 196 |
198 | 199 |
filter_selection() (awesim.Simdex method) 200 |
201 | 202 | 203 |
filter_similar() (awesim.Simdex method) 204 |
205 | 206 |
208 | 209 |

G

210 | 211 | 225 | 235 |
212 | 213 |
get() (awesim.Simdex method) 214 |
215 | 216 | 217 |
get_filenames() (awesim.Simdex method) 218 |
219 | 220 | 221 |
get_objects() (awesim.Simulation method) 222 |
223 | 224 |
226 | 227 |
get_SID() (awesim.Simdex method) 228 |
229 | 230 | 231 |
get_value() (awesim.Simulation method) 232 |
233 | 234 |
236 | 237 |

I

238 | 239 | 245 |
240 | 241 |
index_one_sim() (awesim.Simdex method) 242 |
243 | 244 |
246 | 247 |

O

248 | 249 | 255 |
250 | 251 |
openh5() (awesim.Simdex method) 252 |
253 | 254 |
256 | 257 |

P

258 | 259 | 275 | 285 |
260 | 261 |
plot() (awesim.Result method) 262 |
263 | 264 |
265 | 266 |
(awesim.Simdex method) 267 |
268 | 269 |
270 | 271 |
postproc() (awesim.Simdex method) 272 |
273 | 274 |
276 | 277 |
postprocess() (awesim.Simulation method) 278 |
279 | 280 | 281 |
Process (class in awesim) 282 |
283 | 284 |
286 | 287 |

R

288 | 289 | 295 |
290 | 291 |
Result (class in awesim) 292 |
293 | 294 |
296 | 297 |

S

298 | 299 | 323 | 337 |
300 | 301 |
save() (awesim.Result method) 302 |
303 | 304 |
305 | 306 |
(awesim.Simdex method) 307 |
308 | 309 |
310 | 311 |
scan() (awesim.Simdex method) 312 |
313 | 314 | 315 |
scatterplot() (awesim.Simdex method) 316 |
317 | 318 | 319 |
separate() (awesim.Simulation method) 320 |
321 | 322 |
324 | 325 |
Simdex (class in awesim) 326 |
327 | 328 | 329 |
Simulation (class in awesim) 330 |
331 | 332 | 333 |
smooth() (awesim.Result method) 334 |
335 | 336 |
338 | 339 |

T

340 | 341 | 347 | 353 |
342 | 343 |
to_dataframe() (awesim.Result method) 344 |
345 | 346 |
348 | 349 |
trapz() (awesim.Result method) 350 |
351 | 352 |
354 | 355 |

V

356 | 357 | 363 |
358 | 359 |
values() (awesim.Result method) 360 |
361 | 362 |
364 | 365 | 366 | 367 |
368 |
369 |
370 |
371 |
372 | 373 | 374 | 375 | 387 | 388 |
389 |
390 |
391 |
392 | 401 | 405 | 406 | -------------------------------------------------------------------------------- /doc/build/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | awesim — awesim 0.1 documentation 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 |

awesim

52 |

Optimize your simulation workflow.

53 |

awesim is written in Python and contains tools for pre- and post-processing of Modelica models.

54 |

With awesim you can:

55 |
56 |
    57 |
  1. compile models, set parameters and solver options and start simulations
  2. 58 |
  3. run simulations in parallel on the same computer or different machines
  4. 59 |
  5. open result files, access simulation parameters and trajectories, make plots
  6. 60 |
  7. keep an overview of your cases by creating an index (called simdex) of different results
  8. 61 |
  9. filter your results based on filenames or parameter sets
  10. 62 |
63 |
64 |

Most of the tools provided are currently based on Dymola and the .mat result file.

65 |

awesim is licensed under the xxx license.

66 |
67 |
68 |

Contents

69 | 82 |
83 |
84 |

Indices and tables

85 | 90 |
91 | 92 | 93 |
94 |
95 |
96 |
97 |
98 |

Table Of Contents

99 | 106 | 107 |

Next topic

108 |

Working with single simulations

110 |

This Page

111 | 115 | 127 | 128 |
129 |
130 |
131 |
132 | 144 | 148 | 149 | -------------------------------------------------------------------------------- /doc/build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/build/html/objects.inv -------------------------------------------------------------------------------- /doc/build/html/process.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Defining a post-process — awesim 0.1 documentation 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |

Defining a post-process

56 |

Post-processing is the data treatment that is unavoidable after running your simulations. There are different things to get done:

57 |
    58 |
  • extract all useful information from the simulation file(s)
  • 59 |
  • treat the results: number crunching like scaling, integration, aggregation, or simple arithmetic operations
  • 60 |
  • compare results of different runs with plots, tables, etc.
  • 61 |
  • store your results for later use
  • 62 |
63 |

Post processing is often a time-intensive step in the simulation set-up. To ease often used post-processing operations, awsim defines a Process class. A Process is a set of operations that can be executed on a Simulation instance. Let’s start with a simple example.

64 |
In [1]: import numpy as np
 65 | 
 66 | In [2]: from awesim import Simulation, Process
 67 | 
68 |
69 |
In [3]: process = Process(variables={'T': 'c1.T'})
 70 | 
 71 | In [4]: print process
 72 | 
 73 | -------------------------------------------------------------------------------
 74 | The content of this Process object is:
 75 | Parameters:
 76 | Variables:
 77 | 	T	=	c1.T
 78 | 	Time	=	Time
 79 | Post-processing:
 80 | 
81 |
82 |

This process has a dictionary variables that contains a mapping of short to full variable names. You’ll notice that the variable ‘Time’ is automatically added to the variables. When we apply this simple process to a Simulation, the result will be the same as invoking simulation.extract(process.variables)

83 |
In [5]: sim = Simulation('LinkedCapacities')
 84 | 
 85 | In [6]: sim.postprocess(process)
 86 | Out[6]: 
 87 | {'T': array([ 400.  ,  394.91,  390.63,  387.06,  384.08,  381.59,  379.5 ,
 88 |         377.76,  376.3 ,  375.07,  374.04,  373.18,  372.46,  371.86,
 89 |         371.35,  370.92,  370.57,  370.27,  370.02,  369.81,  369.64,
 90 |         369.5 ,  369.38,  369.28,  369.2 ,  369.13,  369.07,  369.02,
 91 |         368.97,  368.94,  368.91,  368.88,  368.86,  368.84,  368.83,
 92 |         368.82,  368.81,  368.8 ,  368.79,  368.78,  368.78,  368.77,
 93 |         368.77,  368.76,  368.76,  368.76,  368.76,  368.75,  368.75,
 94 |         368.75,  368.75], dtype=float32),
 95 |  'Time': array([     0.,    200.,    400.,    600.,    800.,   1000.,   1200.,
 96 |          1400.,   1600.,   1800.,   2000.,   2200.,   2400.,   2600.,
 97 |          2800.,   3000.,   3200.,   3400.,   3600.,   3800.,   4000.,
 98 |          4200.,   4400.,   4600.,   4800.,   5000.,   5200.,   5400.,
 99 |          5600.,   5800.,   6000.,   6200.,   6400.,   6600.,   6800.,
100 |          7000.,   7200.,   7400.,   7600.,   7800.,   8000.,   8200.,
101 |          8400.,   8600.,   8800.,   9000.,   9200.,   9400.,   9600.,
102 |          9800.,  10000.], dtype=float32)}
103 | 
104 |
105 |

If we need parameter values in the postprocessing, we can add (or edit) the attribute parameters.

106 |
In [7]: process.parameters = {'c1': 'c1.C', 'c2': 'c2.C'}
107 | 
108 | In [8]: print process
109 | 
110 | -------------------------------------------------------------------------------
111 | The content of this Process object is:
112 | Parameters:
113 | 	c1	=	c1.C
114 | 	c2	=	c2.C
115 | Variables:
116 | 	T	=	c1.T
117 | 	Time	=	Time
118 | Post-processing:
119 | 
120 |
121 |

One of the main uses of the process class is the definition of post-processing actions. These are defined as strings. A simple example could be the conversion of the temperature of capacity c1 from Kelvin to degree Celsius.

122 |
In [9]: post_proc_string = 'T_degC = T - 273.15'
123 | 
124 | In [10]: process.pp.append(post_proc_string)
125 | 
126 | In [11]: sim.postprocess(process)
127 | Out[11]: 
128 | {'T': array([ 400.  ,  394.91,  390.63,  387.06,  384.08,  381.59,  379.5 ,
129 |         377.76,  376.3 ,  375.07,  374.04,  373.18,  372.46,  371.86,
130 |         371.35,  370.92,  370.57,  370.27,  370.02,  369.81,  369.64,
131 |         369.5 ,  369.38,  369.28,  369.2 ,  369.13,  369.07,  369.02,
132 |         368.97,  368.94,  368.91,  368.88,  368.86,  368.84,  368.83,
133 |         368.82,  368.81,  368.8 ,  368.79,  368.78,  368.78,  368.77,
134 |         368.77,  368.76,  368.76,  368.76,  368.76,  368.75,  368.75,
135 |         368.75,  368.75], dtype=float32),
136 |  'T_degC': array([ 126.85,  121.76,  117.48,  113.91,  110.93,  108.44,  106.35,
137 |         104.61,  103.15,  101.92,  100.89,  100.03,   99.31,   98.71,
138 |          98.2 ,   97.77,   97.42,   97.12,   96.87,   96.66,   96.49,
139 |          96.35,   96.23,   96.13,   96.05,   95.98,   95.92,   95.87,
140 |          95.82,   95.79,   95.76,   95.73,   95.71,   95.69,   95.68,
141 |          95.67,   95.66,   95.65,   95.64,   95.63,   95.63,   95.62,
142 |          95.62,   95.61,   95.61,   95.61,   95.61,   95.6 ,   95.6 ,
143 |          95.6 ,   95.6 ], dtype=float32),
144 |  'Time': array([     0.,    200.,    400.,    600.,    800.,   1000.,   1200.,
145 |          1400.,   1600.,   1800.,   2000.,   2200.,   2400.,   2600.,
146 |          2800.,   3000.,   3200.,   3400.,   3600.,   3800.,   4000.,
147 |          4200.,   4400.,   4600.,   4800.,   5000.,   5200.,   5400.,
148 |          5600.,   5800.,   6000.,   6200.,   6400.,   6600.,   6800.,
149 |          7000.,   7200.,   7400.,   7600.,   7800.,   8000.,   8200.,
150 |          8400.,   8600.,   8800.,   9000.,   9200.,   9400.,   9600.,
151 |          9800.,  10000.], dtype=float32),
152 |  'c1': array([ 600.]),
153 |  'c2': array([ 1000.])}
154 | 
155 |
156 |

You’ll notice that we have created a new variable, T_degC which is added to the result of the post-processing. Note that in the post-processing string, we were able to use the shortname ‘T’ that was introduced as key in the variables of the process.

157 |
158 | 159 | 160 |
161 |
162 |
163 |
164 |
165 |

Previous topic

166 |

Working with single simulations

168 |

Next topic

169 |

Class overview

171 |

This Page

172 | 176 | 188 | 189 |
190 |
191 |
192 |
193 | 208 | 212 | 213 | -------------------------------------------------------------------------------- /doc/build/html/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Search — awesim 0.1 documentation 12 | 13 | 14 | 15 | 16 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 46 | 47 |
48 |
49 |
50 |
51 | 52 |

Search

53 |
54 | 55 |

56 | Please activate JavaScript to enable the search 57 | functionality. 58 |

59 |
60 |

61 | From here you can search these documents. Enter your search 62 | words into the box below and click "search". Note that the search 63 | function will automatically search for all of the words. Pages 64 | containing fewer words won't appear in the result list. 65 |

66 |
67 | 68 | 69 | 70 |
71 | 72 |
73 | 74 |
75 | 76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | 94 | 98 | 99 | -------------------------------------------------------------------------------- /doc/build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({objects:{"awesim.Simulation":{analyse_cputime:[0,1,1,""],separate:[0,1,1,""],get_value:[0,1,1,""],exist:[0,1,1,""],"__init__":[0,1,1,""],postprocess:[0,1,1,""],extract:[0,1,1,""],get_objects:[0,1,1,""]},awesim:{Process:[0,2,1,""],Simdex:[0,2,1,""],Result:[0,2,1,""],Simulation:[0,2,1,""]},"awesim.Result":{plot:[0,1,1,""],trapz:[0,1,1,""],smooth:[0,1,1,""],values:[0,1,1,""],aggregate:[0,1,1,""],save:[0,1,1,""],"__weakref__":[0,0,1,""],to_dataframe:[0,1,1,""],"__init__":[0,1,1,""]},"awesim.Process":{"__str__":[0,1,1,""],"__weakref__":[0,0,1,""],"__init__":[0,1,1,""]},"awesim.Simdex":{"_last_key":[0,1,1,""],scan:[0,1,1,""],"_get_par":[0,1,1,""],"__str__":[0,1,1,""],exist:[0,1,1,""],apply:[0,1,1,""],"_Simdex__get_files":[0,1,1,""],"__init__":[0,1,1,""],plot:[0,1,1,""],get_SID:[0,1,1,""],"_gen_key":[0,1,1,""],cleanup:[0,1,1,""],"_get_var_h5":[0,1,1,""],filter_remove:[0,1,1,""],save:[0,1,1,""],postproc:[0,1,1,""],get_filenames:[0,1,1,""],get:[0,1,1,""],openh5:[0,1,1,""],scatterplot:[0,1,1,""],filter_selection:[0,1,1,""],filter:[0,1,1,""],index_one_sim:[0,1,1,""],filter_similar:[0,1,1,""]}},terms:{all:[0,2,3],get_object:[0,3],correl:0,follow:[0,3],children:0,content:[2,1],privat:0,middl:0,depend:0,sensit:0,d_1:0,present:0,under:[0,1],introduc:2,everi:0,string:[0,2],straightforward:0,fals:0,cputim:0,exact:0,solver:1,list:[0,3],item:0,cc81f26844d0:[],"2b2aeac5e8bb":[],aggreg:[0,2],pass:0,panda:0,append:[0,2],even:[0,3],index:[0,1,3],what:0,awsim:2,sub:[0,3],t_degc:2,vardic:0,neg:0,sum:[0,3],introspect:3,abl:2,invok:2,current:[0,1],importerror:[],version:0,"new":[0,2],method:[0,3],crunch:2,q_flow:[0,3],full:[0,2],resampl:0,gener:0,here:[0,3],satisfi:[0,3],let:2,path:0,dymola:[0,1],e0d948a42bdf:[],legend:0,valu:[0,2,3],search:[0,1,3],convers:2,hdf5:0,rdc:0,action:[0,2],implement:0,"5ef7913e369":[],appli:[0,2],modul:1,put:0,total:[0,3],select:0,"_simdex__get_fil":0,regex:0,plot:[0,1,2,3],from:[0,2,3],zip:3,memori:[0,3],distinct:0,scan:0,two:3,get_filenam:0,a5e6477fe931:[],call:[0,1,3],postprocess:[0,2,3],criteria:0,taken:3,more:[0,3],sort:0,desir:0,successful:0,ylabel:0,notic:2,known:3,cumul:0,none:0,hour:0,analys:0,der:3,work:[0,1,3],uniqu:0,can:[0,1,2,3],root:3,"14a2e4c0f985":[],def:3,traceback:[],want:[0,3],give:0,process:[0,1,2,3],celsiu:2,backslash:0,indic:[0,1],tab:0,sought:0,multlin:0,unavoid:2,alwai:[0,3],end:0,foreseen:3,till:0,"__init__":0,sid:0,verifi:0,simpl:[0,2],sim:[2,3],updat:0,map:[0,2],mat:[0,1,3],mess:0,after:[0,2],variant:0,befor:0,attent:0,mai:0,multipl:0,data:[0,2,3],parallel:1,averag:0,reshap:0,"short":[0,2],practic:3,read:[0,3],correspond:0,element:0,caus:0,inform:2,sidxxxx:0,combin:0,order:0,fc0b2f151343:[],composit:0,over:0,becaus:0,sim_id:0,"_last_kei":0,through:3,variablemap:0,still:0,mainli:0,paramet:[0,1,2,3],get_valu:[0,3],how:0,post_proc_str:2,tstart:[0,3],main:[0,2],them:0,good:0,"return":[0,3],thei:0,python:[1,3],dai:0,document:[0,3],name:[0,2,3],changelog:0,edit:2,didn:0,unpickl:0,nameerror:[],modelica:1,mode:0,full_nam:0,heatport:3,found:0,complet:0,mean:[0,3],compil:1,replac:[0,3],hard:0,idea:0,variablenam:0,our:3,energi:3,"553bb81a50af":[],extract:[0,2,3],event:0,out:[2,3],variabl:[0,2,3],datainfo:0,space:0,crucial:0,profil:0,backlslash:0,adapt:0,rel:0,print:[0,2,3],formula:0,correct:0,multilin:0,workflow:1,"929b94aec857":[],given:[0,3],folderlist:0,reason:[0,3],base:[0,1],dictionari:[0,2,3],"_gen_kei":0,ask:0,longnam:0,wai:3,could:[0,2],omit:0,keep:[0,1],filter:[0,1],thing:[0,2],length:[0,3],assign:0,first:[0,3],oper:[0,2],directli:0,arrai:[0,2,3],number:[0,2],alreadi:0,done:[0,2],overwrit:0,open:[0,1],size:0,differ:[0,1,2,3],convent:0,licens:1,capac:2,paramt:3,statement:[0,3],smoothen:0,cvalu:3,conveni:3,store:[0,2,3],multistat:0,option:[0,1,3],tool:1,copi:0,specifi:0,"_get_var_h5":0,part:0,scatterplot:0,exactli:0,"856a31ca6ceb":[],sub_var:0,c1_q_int:0,provid:[0,1],remov:0,second:[0,3],structur:0,charact:0,str:3,were:2,consumpt:0,minut:0,pre:[0,1],comput:[0,1],trapz:[0,3],argument:[0,3],have:[0,2,3],tabl:[2,1],need:[0,2],seem:0,instanct:0,discfulldyn20:0,self:[0,3],simul:[0,1,2,3],note:[2,3],also:0,exampl:[0,2,3],take:[0,3],which:[0,2,3],analogu:0,data1:0,singl:[0,1,3],data2:0,therefor:0,unless:0,get_sid:0,multipli:0,object:[0,2,3],most:[0,1],regular:[0,3],pair:0,"class":[0,1,2,3],compar:2,tinitialvalu:0,function_cal:0,later:[0,2],flow:3,drive:0,doe:0,sub_par:0,shortnam:[0,2],axi:0,datafram:0,show:0,"462017d98078":[],"__str__":0,verbos:0,syntax:0,to_datafram:0,fine:0,line:0,absolut:0,onli:0,criterium:3,"true":[0,3],explain:3,solut:0,figur:0,should:0,suppos:[0,3],factor:0,filter_remov:0,folder:0,local:0,"21a3a4df46d6":[],unus:0,get:[0,2,3],express:[0,3],stop:0,parametermap:0,requir:0,retreiv:0,enabl:0,qheat:0,integr:[0,2],contain:[0,1,2,3],recompos:0,set:[0,1,2],resist:3,pardic:0,see:[0,3],result:[0,1,2,3],"2f27183cbaa8":[],detect:0,kei:[0,2,3],"__weakref__":0,simdex:[0,1,3],label:0,written:1,between:[0,3],q_sum:3,"import":[0,2,3],attribut:[0,2,3],accord:0,syntact:0,parent:3,weak:0,heatport_a:3,heatport_b:3,extens:[0,3],matplotlib:0,otherwis:0,ipython:3,toler:0,b77439b1f7ba:[],parametervalu:[0,3],last:0,"89aa9f0f9caf":[],etc:2,instanc:[0,2],improv:0,filter_similar:0,"46b444ad78da":[],load:0,point:0,instanti:[0,3],overview:[0,1],period:0,solv:0,duplic:0,becom:0,short_nam:0,numpi:[0,2,3],three:3,empti:0,treat:[0,2],long_nam:0,trajectori:[0,1,3],foobar:0,nonwildcardpattern:0,"750cc8c03a6c":[],xxx:1,convert:0,ani:0,openh5:0,input:[0,3],those:0,"case":[0,1],multi:0,ident:0,look:0,porcess:0,filter_select:0,defin:[0,1,2],calcul:0,index_one_sim:0,match:0,pytabl:0,separ:[0,3],load_simdex:0,"4b0395666eac":[],kwarg:0,sever:0,par:0,develop:0,cpickl:0,make:[0,1],same:[0,1,2,3],check:0,binari:0,split:[0,3],simid:0,filterset:0,d_12_tsto:0,optim:1,kelvin:2,moment:3,rais:0,robust:0,typic:0,recent:[],entri:0,well:0,pickl:0,without:[0,3],command:0,thi:[0,2,3],mother:0,model:[0,1],roughli:0,left:0,identifi:0,just:3,"_dot_":0,when:[0,2,3],obtain:3,weekli:0,speed:0,yet:0,versu:0,easi:0,screendump:0,except:0,add:[0,2],treatment:2,"_get_par":0,els:0,save:0,float32:[2,3],build:0,bin:0,format:0,handl:0,big:0,filenamesfrom:0,temperatur:2,know:0,bit:0,like:[0,2],filenam:[0,1,3],awesim:[0,1,2,3],integ:0,unnecessari:0,tsto:0,right:0,often:2,interv:0,some:0,intern:0,home:3,b6609a236e5:[],txt:0,definit:2,track:0,larg:3,foo:0,"5371fdc4b959":[],refer:0,machin:1,t_arrai:3,who:0,run:[0,1,2],timeseri:0,each:[0,3],excap:0,step:2,post:[0,1,2],analyse_cputim:0,get_paramet:0,surround:0,page:1,degre:2,intens:[0,2],stand:0,subset:0,f079b5ac22ab:[],objectnam:0,"float":[0,3],automat:[0,2,3],c2_q_int:0,chang:0,your:[2,1,3],merg:0,shortname_int:0,val:0,few:0,execut:[0,2],support:0,"long":0,start:[0,1,2,3],arithmet:2,"var":[0,3],postproc:0,"function":0,form:0,basic:0,link:0,eas:2,dtype:[2,3],info:0,electr:0,made:0,happen:0,possibl:[0,3],"default":[0,3],wish:0,access:[1,3],smooth:0,ce4a565d77d1:[],limit:0,trapezoid:0,similar:0,featur:0,creat:[0,1,2,3],timespan:0,"int":0,year:0,doesn:0,exist:[0,3],file:[0,1,2,3],getident:0,simman:0,nan:0,timecheck:0,cleanup:0,test:[0,3],you:[0,1,2,3],non_wildcard_pattern:0,nice:0,"5d776695fc19":[],roel:3,relat:[0,3],linkedcapac:[2,3],nakedtab:0,meaning:0,scale:[0,2],"9458b94b80ac":[],directori:0,rule:0,time:[0,2,3],escap:0,daili:0},objtypes:{"0":"py:attribute","1":"py:method","2":"py:class"},titles:["Class overview","awesim","Defining a post-process","Working with single simulations"],objnames:{"0":["py","attribute","Python attribute"],"1":["py","method","Python method"],"2":["py","class","Python class"]},filenames:["class_overview","index","process","simulation"]}) -------------------------------------------------------------------------------- /doc/source/DemoProcess.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Nov 23 11:06:19 2011 4 | 5 | @author: RDC 6 | """ 7 | 8 | import simman 9 | from simman import Simulation, Simdex, Process 10 | 11 | mothers=['c1', 'c2'] 12 | parameters={'cap1':'c1.C', 'res':'r.R'} 13 | sub_pars={'cap':'C'} 14 | variables={} 15 | sub_vars={'Qflow':'heatPort.Q_flow'} 16 | pp=['Qflow_kW = 0.001 * Qflow', 'timehours = Time / 3600'] 17 | 18 | process = Process(mothers=mothers, parameters=parameters, 19 | sub_pars=sub_pars, variables=variables, 20 | sub_vars=sub_vars, pp=pp) 21 | 22 | class DummyProcess(object): 23 | def invoke_upper(self): 24 | print locals() 25 | 26 | 27 | 28 | class MyClass(object): 29 | 30 | def __init__(self, process): 31 | self.process=process 32 | 33 | def my_method(self, a, b): 34 | print 'return the sum of ', a, ' and ', b 35 | return a+b 36 | 37 | 38 | dummyprocess=DummyProcess() 39 | 40 | myclass=MyClass(dummyprocess) 41 | 42 | c= myclass.my_method(3, 5.67) 43 | print c 44 | 45 | sim=Simulation('LinkedCapacities.mat', verbose = True) 46 | processed = sim.postprocess(process) 47 | 48 | simdex=Simdex(process=process, verbose = False) 49 | simdex.scan() -------------------------------------------------------------------------------- /doc/source/Overview.emf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/doc/source/Overview.emf -------------------------------------------------------------------------------- /doc/source/class_overview.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _class_overview: 3 | 4 | Class overview 5 | ============== 6 | 7 | Class Simulation 8 | **************** 9 | .. autoclass:: awesim.Simulation 10 | :members: 11 | :private-members: 12 | :special-members: 13 | 14 | Class Process 15 | **************** 16 | .. autoclass:: awesim.Process 17 | :members: 18 | :private-members: 19 | :special-members: 20 | 21 | Class Simdex 22 | **************** 23 | .. autoclass:: awesim.Simdex 24 | :members: 25 | :private-members: 26 | :special-members: 27 | 28 | Class Result 29 | **************** 30 | .. autoclass:: awesim.Result 31 | :members: 32 | :private-members: 33 | :special-members: 34 | -------------------------------------------------------------------------------- /doc/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # SimulationManagement documentation build configuration file, created by 4 | # sphinx-quickstart on Wed Aug 29 15:35:15 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | 20 | sys.path.insert(0, os.path.abspath('.')) 21 | 22 | # -- General configuration ----------------------------------------------------- 23 | 24 | # If your documentation needs a minimal Sphinx version, state it here. 25 | #needs_sphinx = '1.0' 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be extensions 28 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 29 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'ipython_directive', 30 | 'ipython_console_highlighting'] 31 | 32 | # Add any paths that contain templates here, relative to this directory. 33 | templates_path = ['_templates'] 34 | 35 | # The suffix of source filenames. 36 | source_suffix = '.rst' 37 | 38 | # The encoding of source files. 39 | #source_encoding = 'utf-8-sig' 40 | 41 | # The master toctree document. 42 | master_doc = 'index' 43 | 44 | # General information about the project. 45 | project = u'awesim' 46 | copyright = u'2012, Roel De Coninck, Ruben Baetens' 47 | 48 | # The version info for the project you're documenting, acts as replacement for 49 | # |version| and |release|, also used in various other places throughout the 50 | # built documents. 51 | # 52 | # The short X.Y version. 53 | version = '0.1' 54 | # The full version, including alpha/beta/rc tags. 55 | release = '0.1' 56 | 57 | # The language for content autogenerated by Sphinx. Refer to documentation 58 | # for a list of supported languages. 59 | #language = None 60 | 61 | # There are two options for replacing |today|: either, you set today to some 62 | # non-false value, then it is used: 63 | #today = '' 64 | # Else, today_fmt is used as the format for a strftime call. 65 | #today_fmt = '%B %d, %Y' 66 | 67 | # List of patterns, relative to source directory, that match files and 68 | # directories to ignore when looking for source files. 69 | exclude_patterns = [] 70 | 71 | # The reST default role (used for this markup: `text`) to use for all documents. 72 | #default_role = None 73 | 74 | # If true, '()' will be appended to :func: etc. cross-reference text. 75 | #add_function_parentheses = True 76 | 77 | # If true, the current module name will be prepended to all description 78 | # unit titles (such as .. function::). 79 | #add_module_names = True 80 | 81 | # If true, sectionauthor and moduleauthor directives will be shown in the 82 | # output. They are ignored by default. 83 | #show_authors = False 84 | 85 | # The name of the Pygments (syntax highlighting) style to use. 86 | pygments_style = 'sphinx' 87 | 88 | # A list of ignored prefixes for module index sorting. 89 | #modindex_common_prefix = [] 90 | 91 | 92 | # -- Options for HTML output --------------------------------------------------- 93 | 94 | # The theme to use for HTML and HTML Help pages. See the documentation for 95 | # a list of builtin themes. 96 | html_theme = 'default' 97 | 98 | # Theme options are theme-specific and customize the look and feel of a theme 99 | # further. For a list of options available for each theme, see the 100 | # documentation. 101 | #html_theme_options = {} 102 | 103 | # Add any paths that contain custom themes here, relative to this directory. 104 | #html_theme_path = [] 105 | 106 | # The name for this set of Sphinx documents. If None, it defaults to 107 | # " v documentation". 108 | #html_title = None 109 | 110 | # A shorter title for the navigation bar. Default is the same as html_title. 111 | #html_short_title = None 112 | 113 | # The name of an image file (relative to this directory) to place at the top 114 | # of the sidebar. 115 | #html_logo = None 116 | 117 | # The name of an image file (within the static path) to use as favicon of the 118 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 119 | # pixels large. 120 | #html_favicon = None 121 | 122 | # Add any paths that contain custom static files (such as style sheets) here, 123 | # relative to this directory. They are copied after the builtin static files, 124 | # so a file named "default.css" will overwrite the builtin "default.css". 125 | html_static_path = ['_static'] 126 | 127 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 128 | # using the given strftime format. 129 | #html_last_updated_fmt = '%b %d, %Y' 130 | 131 | # If true, SmartyPants will be used to convert quotes and dashes to 132 | # typographically correct entities. 133 | #html_use_smartypants = True 134 | 135 | # Custom sidebar templates, maps document names to template names. 136 | #html_sidebars = {} 137 | 138 | # Additional templates that should be rendered to pages, maps page names to 139 | # template names. 140 | #html_additional_pages = {} 141 | 142 | # If false, no module index is generated. 143 | #html_domain_indices = True 144 | 145 | # If false, no index is generated. 146 | #html_use_index = True 147 | 148 | # If true, the index is split into individual pages for each letter. 149 | #html_split_index = False 150 | 151 | # If true, links to the reST sources are added to the pages. 152 | #html_show_sourcelink = True 153 | 154 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 155 | #html_show_sphinx = True 156 | 157 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 158 | #html_show_copyright = True 159 | 160 | # If true, an OpenSearch description file will be output, and all pages will 161 | # contain a tag referring to it. The value of this option must be the 162 | # base URL from which the finished HTML is served. 163 | #html_use_opensearch = '' 164 | 165 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 166 | #html_file_suffix = None 167 | 168 | # Output file base name for HTML help builder. 169 | htmlhelp_basename = 'SimulationManagementdoc' 170 | 171 | 172 | # -- Options for LaTeX output -------------------------------------------------- 173 | 174 | latex_elements = { 175 | # The paper size ('letterpaper' or 'a4paper'). 176 | #'papersize': 'letterpaper', 177 | 178 | # The font size ('10pt', '11pt' or '12pt'). 179 | #'pointsize': '10pt', 180 | 181 | # Additional stuff for the LaTeX preamble. 182 | #'preamble': '', 183 | } 184 | 185 | # Grouping the document tree into LaTeX files. List of tuples 186 | # (source start file, target name, title, author, documentclass [howto/manual]). 187 | latex_documents = [ 188 | ('index', 'SimulationManagement.tex', u'SimulationManagement Documentation', 189 | u'Roel De Coninck, Ruben Baetens', 'manual'), 190 | ] 191 | 192 | # The name of an image file (relative to this directory) to place at the top of 193 | # the title page. 194 | #latex_logo = None 195 | 196 | # For "manual" documents, if this is true, then toplevel headings are parts, 197 | # not chapters. 198 | #latex_use_parts = False 199 | 200 | # If true, show page references after internal links. 201 | #latex_show_pagerefs = False 202 | 203 | # If true, show URL addresses after external links. 204 | #latex_show_urls = False 205 | 206 | # Documents to append as an appendix to all manuals. 207 | #latex_appendices = [] 208 | 209 | # If false, no module index is generated. 210 | #latex_domain_indices = True 211 | 212 | 213 | # -- Options for manual page output -------------------------------------------- 214 | 215 | # One entry per manual page. List of tuples 216 | # (source start file, name, description, authors, manual section). 217 | man_pages = [ 218 | ('index', 'simulationmanagement', u'SimulationManagement Documentation', 219 | [u'Roel De Coninck, Ruben Baetens'], 1) 220 | ] 221 | 222 | # If true, show URL addresses after external links. 223 | #man_show_urls = False 224 | 225 | 226 | # -- Options for Texinfo output ------------------------------------------------ 227 | 228 | # Grouping the document tree into Texinfo files. List of tuples 229 | # (source start file, target name, title, author, 230 | # dir menu entry, description, category) 231 | texinfo_documents = [ 232 | ('index', 'SimulationManagement', u'SimulationManagement Documentation', 233 | u'Roel De Coninck, Ruben Baetens', 'SimulationManagement', 'One line description of project.', 234 | 'Miscellaneous'), 235 | ] 236 | 237 | # Documents to append as an appendix to all manuals. 238 | #texinfo_appendices = [] 239 | 240 | # If false, no module index is generated. 241 | #texinfo_domain_indices = True 242 | 243 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 244 | #texinfo_show_urls = 'footnote' 245 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | .. awesim documentation master file, created by 2 | sphinx-quickstart on Wed Aug 29 15:35:15 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | awesim 7 | ====== 8 | 9 | *Optimize your simulation workflow.* 10 | 11 | awesim is written in **Python** and contains tools for pre- and post-processing of **Modelica** models. 12 | 13 | With awesim you can: 14 | 15 | 1. compile models, set parameters and solver options and start simulations 16 | 2. run simulations in parallel on the same computer or different machines 17 | 3. open result files, access simulation parameters and trajectories, make plots 18 | 4. keep an overview of your cases by creating an index (called simdex) of different results 19 | 5. filter your results based on filenames or parameter sets 20 | 21 | Most of the tools provided are currently based on Dymola and the .mat result file. 22 | 23 | awesim is licensed under the xxx license. 24 | 25 | 26 | Contents 27 | ======== 28 | 29 | 30 | .. toctree:: 31 | :maxdepth: 2 32 | 33 | simulation 34 | process 35 | simdex 36 | result 37 | class_overview 38 | 39 | 40 | 41 | 42 | Indices and tables 43 | ================== 44 | 45 | * :ref:`genindex` 46 | * :ref:`modindex` 47 | * :ref:`search` 48 | 49 | -------------------------------------------------------------------------------- /doc/source/ipython_console_highlighting.py: -------------------------------------------------------------------------------- 1 | """reST directive for syntax-highlighting ipython interactive sessions. 2 | 3 | XXX - See what improvements can be made based on the new (as of Sept 2009) 4 | 'pycon' lexer for the python console. At the very least it will give better 5 | highlighted tracebacks. 6 | """ 7 | 8 | #----------------------------------------------------------------------------- 9 | # Needed modules 10 | 11 | # Standard library 12 | import re 13 | 14 | # Third party 15 | from pygments.lexer import Lexer, do_insertions 16 | from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer, 17 | PythonTracebackLexer) 18 | from pygments.token import Comment, Generic 19 | 20 | from sphinx import highlighting 21 | 22 | #----------------------------------------------------------------------------- 23 | # Global constants 24 | line_re = re.compile('.*?\n') 25 | 26 | #----------------------------------------------------------------------------- 27 | # Code begins - classes and functions 28 | 29 | class IPythonConsoleLexer(Lexer): 30 | """ 31 | For IPython console output or doctests, such as: 32 | 33 | .. sourcecode:: ipython 34 | 35 | In [1]: a = 'foo' 36 | 37 | In [2]: a 38 | Out[2]: 'foo' 39 | 40 | In [3]: print a 41 | foo 42 | 43 | In [4]: 1 / 0 44 | 45 | Notes: 46 | 47 | - Tracebacks are not currently supported. 48 | 49 | - It assumes the default IPython prompts, not customized ones. 50 | """ 51 | 52 | name = 'IPython console session' 53 | aliases = ['ipython'] 54 | mimetypes = ['text/x-ipython-console'] 55 | input_prompt = re.compile("(In \[[0-9]+\]: )|( \.\.\.+:)") 56 | output_prompt = re.compile("(Out\[[0-9]+\]: )|( \.\.\.+:)") 57 | continue_prompt = re.compile(" \.\.\.+:") 58 | tb_start = re.compile("\-+") 59 | 60 | def get_tokens_unprocessed(self, text): 61 | pylexer = PythonLexer(**self.options) 62 | tblexer = PythonTracebackLexer(**self.options) 63 | 64 | curcode = '' 65 | insertions = [] 66 | for match in line_re.finditer(text): 67 | line = match.group() 68 | input_prompt = self.input_prompt.match(line) 69 | continue_prompt = self.continue_prompt.match(line.rstrip()) 70 | output_prompt = self.output_prompt.match(line) 71 | if line.startswith("#"): 72 | insertions.append((len(curcode), 73 | [(0, Comment, line)])) 74 | elif input_prompt is not None: 75 | insertions.append((len(curcode), 76 | [(0, Generic.Prompt, input_prompt.group())])) 77 | curcode += line[input_prompt.end():] 78 | elif continue_prompt is not None: 79 | insertions.append((len(curcode), 80 | [(0, Generic.Prompt, continue_prompt.group())])) 81 | curcode += line[continue_prompt.end():] 82 | elif output_prompt is not None: 83 | # Use the 'error' token for output. We should probably make 84 | # our own token, but error is typicaly in a bright color like 85 | # red, so it works fine for our output prompts. 86 | insertions.append((len(curcode), 87 | [(0, Generic.Error, output_prompt.group())])) 88 | curcode += line[output_prompt.end():] 89 | else: 90 | if curcode: 91 | for item in do_insertions(insertions, 92 | pylexer.get_tokens_unprocessed(curcode)): 93 | yield item 94 | curcode = '' 95 | insertions = [] 96 | yield match.start(), Generic.Output, line 97 | if curcode: 98 | for item in do_insertions(insertions, 99 | pylexer.get_tokens_unprocessed(curcode)): 100 | yield item 101 | 102 | 103 | def setup(app): 104 | """Setup as a sphinx extension.""" 105 | 106 | # This is only a lexer, so adding it below to pygments appears sufficient. 107 | # But if somebody knows that the right API usage should be to do that via 108 | # sphinx, by all means fix it here. At least having this setup.py 109 | # suppresses the sphinx warning we'd get without it. 110 | pass 111 | 112 | #----------------------------------------------------------------------------- 113 | # Register the extension as a valid pygments lexer 114 | highlighting.lexers['ipython'] = IPythonConsoleLexer() 115 | -------------------------------------------------------------------------------- /doc/source/process.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _process: 3 | 4 | Defining a post-process 5 | ======================= 6 | 7 | Post-processing is the data treatment that is unavoidable after running your simulations. There are different things to get done: 8 | 9 | * extract all useful information from the simulation file(s) 10 | * treat the results: number crunching like scaling, integration, aggregation, or simple arithmetic operations 11 | * compare results of different runs with plots, tables, etc. 12 | * store your results for later use 13 | 14 | Post processing is often a time-intensive step in the simulation set-up. To ease often used post-processing operations, awsim defines a Process class. A Process is a set of operations that can be executed on a Simulation instance. Let's start with a simple example. 15 | 16 | .. ipython:: python 17 | :suppress: 18 | 19 | import os 20 | print os.getcwd() 21 | os.chdir('../tests') 22 | print os.getcwd() 23 | 24 | .. ipython:: python 25 | 26 | import numpy as np 27 | from awesim import Simulation, Process 28 | 29 | .. ipython:: python 30 | :suppress: 31 | 32 | np.set_printoptions(precision=2, suppress=True) 33 | 34 | .. ipython:: python 35 | 36 | process = Process(variables={'T': 'c1.T'}) 37 | print process 38 | 39 | This process has a dictionary ``variables`` that contains a mapping of short to full variable names. You'll notice that the variable 'Time' is automatically added to the variables. When we apply this simple process to a Simulation, the result will be the same as invoking ``simulation.extract(process.variables)`` 40 | 41 | .. ipython:: python 42 | 43 | sim = Simulation('LinkedCapacities') 44 | sim.postprocess(process) 45 | 46 | If we need parameter values in the postprocessing, we can add (or edit) the attribute ``parameters``. 47 | 48 | .. ipython:: python 49 | 50 | process.parameters = {'c1': 'c1.C', 'c2': 'c2.C'} 51 | print process 52 | 53 | One of the main uses of the process class is the definition of post-processing actions. These are defined as strings. A simple example could be the conversion of the temperature of capacity c1 from Kelvin to degree Celsius. 54 | 55 | .. ipython:: python 56 | 57 | post_proc_string = 'T_degC = T - 273.15' 58 | process.pp.append(post_proc_string) 59 | sim.postprocess(process) 60 | 61 | You'll notice that we have created a new variable, T_degC which is added to the result of the post-processing. Note that in the post-processing string, we were able to use the shortname 'T' that was introduced as key in the ``variables`` of the process. 62 | -------------------------------------------------------------------------------- /doc/source/simulation.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: awesim 2 | .. _simulation: 3 | 4 | Working with single simulations 5 | =============================== 6 | 7 | To get started, we'll always use the following import statements 8 | 9 | .. ipython:: python 10 | :suppress: 11 | 12 | import os 13 | print os.getcwd() 14 | os.chdir('../tests') 15 | print os.getcwd() 16 | 17 | .. ipython:: python 18 | 19 | import numpy as np 20 | from awesim import Simulation 21 | 22 | .. ipython:: python 23 | :suppress: 24 | 25 | np.set_printoptions(precision=2, suppress=True) 26 | 27 | Suppose we have a simulation result file called 'LinkedCapacities.mat'. 28 | We can instantiate a :class:'~awesim.Simulation' object from this file. 29 | 30 | .. ipython:: python 31 | 32 | sim = Simulation('LinkedCapacities') #with our without .mat extension 33 | print sim 34 | 35 | When instantiating a Simulation object, the .mat file is read in memory. 36 | The filename is stored as an attribute. 37 | 38 | .. ipython:: python 39 | 40 | sim.filename 41 | 42 | A simulation object can be introspected in different ways. A list of all 43 | known parameters and variables can be obtained. For large simulations, the method ``get_objects()`` will be more practical. It lists all the sub-objects from a given parent. The simulation root will be taken if no parent is given. 44 | .. ipython:: python 45 | 46 | sim.names 47 | sim.get_objects() 48 | sim.get_objects('C1') 49 | 50 | The list of known names can be split in parameters and variables with the method ``separate()``. 51 | This will create three attributes: 52 | 53 | 1. ``Simulation.variables`` 54 | 2. ``Simulation.parameters`` 55 | 3. ``Simulation.parametervalues`` 56 | 57 | .. ipython:: python 58 | 59 | sim.separate() 60 | sim.variables 61 | for p,v in zip(sim.parameters, sim.parametervalues): 62 | print p, ' = ', str(v) 63 | 64 | A search method is foreseen: ``Simulation.exist()``. It will return a list of all names that satisfy the search criterium. You can even use regular expressions in your search. 65 | 66 | .. ipython:: python 67 | 68 | sim.exist('q_flow') 69 | 70 | There are two methods to obtain the values. The first one is ``Simulation.get_value()``. This method will return a numpy.float for paramters and a numpy.array for trajectories (variables). 71 | 72 | Note: the simulation time is always accessible through 'Time' 73 | 74 | .. ipython:: python 75 | 76 | time = sim.get_value('Time') 77 | Q = sim.get_value(u'r.heatPort_a.Q_flow') 78 | Q_sum = np.trapz(Q, time) 79 | print "The total energy that flowed through the resistance is %.1f J" %Q_sum 80 | 81 | The second method is ``Simulation.extract()``:: 82 | 83 | def extract(self, var, arrays='sum'): 84 | """ 85 | Return dictionary with values of the variables/parameters to extract. 86 | """ 87 | 88 | extract() takes a dictionary as input argument, and will return a dictionary of the same length with the same keys. The variable or parameter names will be replaced with their values. 89 | 90 | .. ipython:: python 91 | 92 | sim.extract({'c1': 'c1.C', 'T1': 'c1.T', 'Q1':'c1.heatPort.Q_flow'}) 93 | 94 | If you want to extract an array of variables, just replace the index (between the []) by 'x'. 95 | There are three possible options for the processing of arrays: 96 | 97 | #. arrays='each': return each of the arrays 98 | #. arrays='sum': return the sum (default) 99 | #. arrays='mean': return the mean 100 | 101 | Here's an example of a simulation result file that contains arrays. 102 | 103 | .. ipython:: python 104 | 105 | sim = Simulation('Array.mat') 106 | sim.get_objects() 107 | sim.extract({'T_array': 'c[x].T'}, arrays='each') 108 | sim.extract({'T_array': 'c[x].T'}, arrays='mean') 109 | 110 | There is one more method in the Simulation class: ``postprocess()``. This method is related to the Result class, it will be explained in the documentation of Result. 111 | 112 | At this moment, there is no automatic plotting method in Simulation. The reason is that is is more convenient to work with the Simdex class, which has methods for plotting. See the documentation of Simdex. 113 | 114 | -------------------------------------------------------------------------------- /examples/DemoProcess.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Nov 23 11:06:19 2011 4 | 5 | @author: RDC 6 | """ 7 | 8 | import simman 9 | reload(simman) 10 | from simman import Simulation, Simdex, Process 11 | 12 | mothers=['c1', 'c2'] 13 | parameters={'cap1':'c1.C', 'res':'r.R'} 14 | sub_pars={'cap':'C'} 15 | variables={} 16 | sub_vars={'Qflow':'heatPort.Q_flow'} 17 | pp=['Qflow_kW = 0.001 * Qflow', 'timehours = Time / 3600'] 18 | 19 | process = Process(mothers=mothers, parameters=parameters, 20 | sub_pars=sub_pars, variables=variables, 21 | sub_vars=sub_vars, pp=pp) 22 | 23 | class DummyProcess(object): 24 | def invoke_upper(self): 25 | print locals() 26 | 27 | 28 | 29 | class MyClass(object): 30 | 31 | def __init__(self, process): 32 | self.process=process 33 | 34 | def my_method(self, a, b): 35 | print 'return the sum of ', a, ' and ', b 36 | return a+b 37 | 38 | 39 | dummyprocess=DummyProcess() 40 | 41 | myclass=MyClass(dummyprocess) 42 | 43 | c= myclass.my_method(3, 5.67) 44 | print c 45 | 46 | sim=Simulation('LinkedCapacities.mat', verbose = True) 47 | processed = sim.postprocess(process) 48 | 49 | simdex=Simdex(process=process, verbose = False) 50 | simdex.scan() -------------------------------------------------------------------------------- /examples/demo_simman.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | Demonstration of the Simdex and Simulation classes from 5 | simman.py 6 | 7 | Created on Thu Feb 17 11:36:47 2011 8 | 9 | @author: RDC 10 | """ 11 | 12 | import numpy as np 13 | import os 14 | from awesim import Simulation, Simdex, Process, load_simdex 15 | 16 | path = os.path.join(os.path.split(os.getcwd())[0], 'tests') 17 | 18 | # first, test the package 19 | #runfile(r'C:\Workspace\Python\SimulationManagement\test_simman.py', 20 | # wdir=r'C:\Workspace\Python\SimulationManagement') 21 | 22 | # a Simulation is a python object for 1 simulation result file 23 | 24 | sim=Simulation(os.path.join(path, 'LinkedCapacities_A')) #with our without .mat extension 25 | sim.separate() # optional, makes attributes for parameters and variables 26 | 27 | sim.parameters 28 | sim.variables 29 | 30 | # in big simulation files, it's not always easy to find the right parameter 31 | # or variable 32 | sim.exist('q_flow') 33 | 34 | time = sim.get_value('Time') 35 | Q = sim.get_value(u'r.heatPort_a.Q_flow') 36 | Q_sum = np.trapz(Q, time) 37 | print "The total energy that flowed through the resistance is %.1f J" %Q_sum 38 | 39 | for p,v in zip(sim.parameters, sim.parametervalues): 40 | print ''.join([p, ' = ', str(v)]) 41 | 42 | 43 | # there are different ways to create a simdex 44 | 45 | s1 = Simdex() # an empty simdex object 46 | s1.scan(folder=path) # scan current folder and add all found simulation files to the simdex 47 | 48 | s2 = Simdex(os.path.join(path, 'SubfolderWithCrappyFiles'), h5='simdex2.h5') 49 | # create a simdex directly from a folder 50 | 51 | print s1 52 | print s2 53 | 54 | # now, let's look at some attributes 55 | s1.get_filenames() # method, so add () 56 | s1.get_filenames('path') 57 | s1.parameters # attribute, so no () 58 | s1.parametermap 59 | s1.parametervalues 60 | s1.variables 61 | s1.variablemap 62 | s1.h5_path 63 | 64 | # Now look at the h5 file (open it with ViTables) 65 | # Demonstrate natural naming of pytables 66 | s1.openh5() 67 | s1.h5.root.SID0001.r_dot_heatPort_a_dot_Q_flow 68 | s1.h5.root.SID0001.r_dot_heatPort_a_dot_Q_flow.read() 69 | s1.h5.close() 70 | 71 | # Next step: using a process 72 | 73 | p1 = Process(variables={'T1':'c1.T', 'T2':'c2.T', 'dt2':'c[2].der(T)'}) 74 | s1 = Simdex(path, process=p1) 75 | 76 | s1.get('T1').values() 77 | 78 | 79 | mothers=['c1', 'c2'] 80 | parameters={'cap1':'c1.C', 'res':'r.R'} 81 | sub_pars={'cap':'C'} 82 | variables={} 83 | sub_vars={'T':'T', 'Qflow':'heatPort.Q_flow'} 84 | pp=['Qflow_kW = Qflow / 1000.'] 85 | J2kWh = 1e-6/3.6 86 | vars_to_integrate = {'Qflow':J2kWh} 87 | 88 | p = Process(mothers=mothers, parameters=parameters, 89 | sub_pars=sub_pars, variables=variables, 90 | sub_vars=sub_vars, pp=pp, integrate=vars_to_integrate) 91 | 92 | s1 = Simdex(path, process=p) 93 | 94 | # remove a simulation from the simdex manually 95 | s3 = s1.filter_remove(['SID0000']) 96 | print s3 97 | # important: this method and some other methods return a NEW simdex 98 | # if you do not want this, you can do the following 99 | s1 = s1.filter_remove(['SID0000']) 100 | print s1 101 | s1.parametermap 102 | 103 | s1.exist('c2') # returns a list with 2 lists by default: parameters matching 104 | # the regex, and variables matching the regex. 105 | s1.get(u'c1.C') 106 | 107 | # filter options ############################################################## 108 | # based on identity 109 | s3 = s1.filter_similar('SID0002') 110 | # returns a new simdex with all simulations that have the same set of 111 | # parameters (even if they have different values) 112 | 113 | # based on parametervalues 114 | fltr = {'c1.C':800} 115 | s4 = s1.filter(fltr) 116 | 117 | # add a paramter to the filter 118 | fltr2 = {'newParameter' : ''} 119 | s4 = s1.filter(fltr2) 120 | 121 | # plotting 122 | print s1.vardic 123 | s3.plot('c1_T') 124 | s3.scatterplot('c1_T', 'c2_T') 125 | 126 | # saving a specific simdex 127 | s2 = s1.filter(fltr) 128 | s2.save('simdex2') 129 | 130 | 131 | 132 | s = load_simdex('simdex2') 133 | s.plot('c1_T') -------------------------------------------------------------------------------- /scipymio4.patch: -------------------------------------------------------------------------------- 1 | diff -r -u scipy/io/matlab/mio4.py scipy_modified/io/matlab/mio4.py 2 | --- scipy/io/matlab/mio4.py Fri May 6 17:43:10 2011 3 | +++ scipy_modified/io/matlab/mio4.py Fri May 6 12:03:12 2011 4 | @@ -147,7 +147,8 @@ 5 | def get_raw_array(self): 6 | arr = self.read_array().astype(np.uint8) 7 | # ascii to unicode 8 | - S = arr.tostring().decode('ascii') 9 | + # was like this: S = arr.tostring().decode('ascii') 10 | + S = arr.tostring().decode() 11 | return np.ndarray(shape=self.header['dims'], 12 | dtype=np.dtype('U1'), 13 | buffer = np.array(S)).copy() 14 | -------------------------------------------------------------------------------- /scripts/ParRunPostProc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri May 06 10:46:27 2011 4 | 5 | @author: RDC 6 | """ 7 | 8 | from __future__ import division 9 | import os 10 | from shutil import copyfile 11 | import matplotlib.pyplot as plt 12 | import numpy as np 13 | 14 | from simman import Simulation, Simdex 15 | from pymosim import * 16 | 17 | 18 | # Script settings ############################################################# 19 | 20 | analyse_logs = True 21 | get_results = True 22 | make_graphs = True 23 | 24 | vars_to_get = [u'pq[32].vi.i.re', u'dwellings[17].pq.p'] 25 | 26 | 27 | 28 | ############################################################################### 29 | 30 | if analyse_logs: 31 | # make a list of logfiles 32 | fileList = os.listdir(os.getcwd()) 33 | log_files = [f for f in fileList if f.find('dslog_run_') > -1] 34 | mat_files = [f for f in fileList if f.find('result_run_') > -1] 35 | 36 | 37 | logs = [] 38 | for l in log_files: 39 | logs.append(analyse_log(l)) -------------------------------------------------------------------------------- /scripts/ParametricRun.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Apr 04 11:42:03 2011 4 | 5 | @author: RBa 6 | """ 7 | 8 | from __future__ import division 9 | import os 10 | import sys 11 | import matplotlib.pyplot as plt 12 | import numpy as np 13 | import pp 14 | from shutil import rmtree 15 | 16 | import pymosim 17 | from simman import Simulation, Simdex 18 | 19 | sys.path.append(os.path.abspath(r'D:\Ruben_BWK239\GIT_python')) 20 | 21 | # Script settings ############################################################# 22 | setup = False 23 | run_it = False 24 | get_results = True 25 | analyse_results = True 26 | 27 | if setup: 28 | # number of cpu's for the parametric run 29 | ncpus=3 30 | 31 | # directory of the parametric run. Make sure it contains a dsin.txt and 32 | # dymosim.exe and a subfolder 'inputs_pr' with all input files 33 | work_dir = 'C:\\Workspace\\Modelica\\DeVloei\\Work\\ParRun' 34 | 35 | # Specify here the parameters and values for the parametric run 36 | # format: list of ['long_name', [val1, ..., valn], 'short_name'] 37 | pars = [ 38 | # [r'building_forGrid.heaSys.onOffDelay', [900, 2000], 'onOffDelay'], 39 | [r'building_forGrid.heaSys.betaFactorHeatPump', [0.5,0.8], 'beta'], 40 | [r'building_forGrid.whichUser',[3,30], 'user'], 41 | [r'building_forGrid.heaSys.volumeTank',[0.2,0.3, 0.4], 'vol_tank'], 42 | [r'building_forGrid.heaSys.HPControl.dTSafetyTop',[3,4,5], 'dTSafetyTop'] 43 | ] 44 | # Specify the variables required for the analysis 45 | variables = dict(TMixed = u'building_forGrid.heaSys.dHW.TMixed', 46 | m_flowTotal = u'building_forGrid.heaSys.dHW.m_flowTotal', 47 | PEl = u'building_forGrid.heaSys.heatPump.PEl' ) 48 | 49 | """ 50 | Remark: the x- and y-axis for the plots can be defined in the 'analyse_results' 51 | section (you can search for to_plot_x to get there). 52 | """ 53 | 54 | ############################################################################### 55 | os.chdir(os.path.abspath(work_dir)) 56 | 57 | if run_it: 58 | if os.path.exists(os.path.join(work_dir, 'results_pr')): 59 | remove_results = raw_input('Remove the results in results_pr ? (y/n) \n ==> ') 60 | if remove_results == 'y' or remove_results == 'Y': 61 | rmtree(os.path.join(work_dir, 'results_pr')) 62 | else: 63 | raise NotImplementedError("Remove the results_pr folder first !") 64 | 65 | # first we must make a dictionary of the parameteric we want to do 66 | # and we add the parameters and their values we want to run 67 | pars_to_run = {} 68 | for par in pars: 69 | pars_to_run[par[0]] = np.array(par[1]) 70 | 71 | # now we set everything ready for parallel python, the return consistst of a 72 | # list of cd-paths where all sub-sets are located as for parallel python 73 | sub_dir = pymosim.set_parametric_run(work_dir, pars_to_run) 74 | 75 | # initialise parallel python 76 | ppservers=() 77 | job_server = pp.Server(ppservers = ppservers, ncpus=ncpus) 78 | # define the inputs and start the simulations 79 | inputs = tuple(sub_dir) 80 | jobs = [(input, job_server.submit(pymosim.start_parametric_run, args = (input,), modules = ("subprocess","os"))) for input in inputs] 81 | job_server.wait() 82 | job_server.destroy() 83 | 84 | pymosim.close_parametric_run(work_dir, sub_dir) 85 | 86 | ############################################################################### 87 | if get_results: 88 | # make a list of logfiles 89 | os.chdir(os.path.join(work_dir, 'results_pr')) 90 | fileList = os.listdir(os.getcwd()) 91 | log_files = [f for f in fileList if f.find('dslog_run_') > -1] 92 | # mat_files = [f for f in fileList if f.find('result_run_') > -1] 93 | 94 | # results is list with dictionaries containing all useful info from the runs 95 | results = [] 96 | 97 | # first, get info from the log files 98 | for l in log_files: 99 | summary = pymosim.analyse_log(l) 100 | summary['mat_file'] = l.replace('.txt','.mat').replace('dslog', 'result') 101 | results.append(summary) 102 | # suc6 = [l['successful'] for l in logs] checked, all are successful! 103 | 104 | # second, get the used parameters and simulation results 105 | 106 | # paramaeteres = contains short and long names of the parameters we need. 107 | # The data will be extracted from the .mat files and put in a dictionary 108 | # The short names will be the keys in that dictionary 109 | parameters = {} 110 | for par in pars: 111 | parameters[par[2]] = par[0] 112 | 113 | for r in results: 114 | # r is the dictionary containing all results for this specific run 115 | sim = Simulation(r['mat_file']) 116 | # we add info to the dictionary: key = var, values = value for var 117 | for k,v in parameters.iteritems(): 118 | r[k] = sim.get_value(v) 119 | for k,v in variables.iteritems(): 120 | r[k] = sim.get_value(v) 121 | # we also get Time 122 | r['Time'] = sim.get_value('Time') 123 | 124 | ############################################################################### 125 | if analyse_results: 126 | for r in results: 127 | # analyse what you want and add results to the dictionary 128 | TDHW_too_low = np.nonzero(r['TMixed'] < (273.15+45.))[0] 129 | m_flow_discomfort = r['m_flowTotal'][TDHW_too_low] 130 | m_flow_discomfort_weighted = (r['m_flowTotal'] * (273.15+45.-r['TMixed']))[TDHW_too_low] 131 | DHW_discomfort = sum(m_flow_discomfort)/sum(r['m_flowTotal']) 132 | dT_discomfort = sum(m_flow_discomfort_weighted)/sum(m_flow_discomfort) 133 | r['DHW_discomfort'] = DHW_discomfort 134 | r['dT_discomfort'] = dT_discomfort 135 | r['TDHW_min'] = min(r['TMixed']) 136 | r['PEl_total'] = np.trapz(r['PEl'], r['Time'])/1e6 # MJ 137 | 138 | 139 | # make numpy arrays with the values of the things we'd like to plot 140 | # these arrays are named according to the variable they contain!! 141 | # to make the script safe, the arrays are added as attributes to a dummy 142 | # class called arrays. 143 | class Dummy(): 144 | pass 145 | arrays = Dummy() 146 | 147 | # x and y axis of the plots 148 | to_plot_x = ['DHW_discomfort', 'dT_discomfort', 'CPU_time'] 149 | to_plot_y = ['PEl_total', 'dT_discomfort'] 150 | 151 | to_plot = [] 152 | to_plot.extend(to_plot_x) 153 | to_plot.extend(to_plot_y) 154 | # beside results, we also need all parameters 155 | to_plot.extend(parameters.keys()) 156 | 157 | for k in to_plot: 158 | ar = np.array([np.double(d[k]) for d in results]) 159 | exec(''.join(['arrays.', k, '= ar'])) 160 | 161 | # Make the graph(s) ######################################################## 162 | 163 | nb_axes = len(parameters) 164 | if nb_axes < 4: 165 | nb_rows = 1 166 | elif nb_axes < 7: 167 | nb_rows = 2 168 | elif nb_axes < 14: 169 | nb_rows = 3 170 | else: 171 | nb_rows = 4 172 | nb_cols = int(np.ceil(nb_axes/nb_rows)) 173 | 174 | plots_to_make = [(x,y) for x in to_plot_x for y in to_plot_y] 175 | for x,y in plots_to_make: 176 | # make 1 plot for each x-axis / y-axis combination 177 | array_x = eval(''.join(['arrays.', x])) 178 | array_y = eval(''.join(['arrays.', y])) 179 | fig = plt.figure() 180 | for a, par in enumerate(parameters): 181 | # make the subplots, 1 per parameter variation 182 | ax = plt.subplot(nb_rows, nb_cols, a+1) 183 | all_res = ax.plot(array_x, array_y, 184 | color = '0.5', linestyle = '', marker = 'o') 185 | for par_value in pars_to_run[parameters[par]]: 186 | # make the colored subplots for each value of the parameter 187 | rel_diff = (eval(''.join(['arrays.', par])) - par_value)/par_value 188 | index = np.nonzero(np.abs(rel_diff) < 0.001)[0] 189 | array_x_sel = array_x[index] 190 | array_y_sel = array_y[index] 191 | ax.plot(array_x_sel, array_y_sel, linestyle = '', marker = 'o', 192 | label = ''.join([par, '=', str(par_value)])) 193 | ax.set_ylim(top = 1.2 * ax.get_ylim()[1]) 194 | 195 | leg = ax.legend(loc = 'upper right') 196 | for t in leg.get_texts(): 197 | t.set_fontsize('small') # the legend text fontsize 198 | ax.set_xlabel(x) 199 | ax.set_ylabel(y) 200 | fig.suptitle(''.join([y, ' versus ', x])) 201 | 202 | # free the results_pr directory 203 | os.chdir(os.path.abspath(work_dir)) -------------------------------------------------------------------------------- /scripts/SensitivityRun.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Apr 04 11:42:03 2011 4 | 5 | @author: RBa 6 | """ 7 | 8 | from __future__ import division 9 | import os 10 | import sys 11 | import matplotlib.pyplot as plt 12 | import numpy as np 13 | import pp 14 | from shutil import rmtree 15 | 16 | import pymosim 17 | from simman import Simulation, Simdex 18 | 19 | sys.path.append(os.path.abspath(r'D:\Ruben_BWK239\GIT_python')) 20 | 21 | # Script settings ############################################################# 22 | setup_and_run = True 23 | get_results = True 24 | analyse_results = True 25 | 26 | # number of cpu's for the sensitivity run 27 | ncpus=2 28 | 29 | # directory of the sensitivity run. Make sure it contains a dsin.txt and 30 | # dymosim.exe and a subfolder 'inputs_pr' with all input files 31 | work_dir = u'C:\\Users\\u0066125\\Workspace\\BS2011\\PP' 32 | 33 | # the sensitivity for the sensitivity analysis. For all variables, a 34 | # run will be executed with (1-sensitivity) * default and 35 | # (1+sensitivity) * default. 36 | sensitivity = 0.2 37 | 38 | # Specify here the parameters and values for the sensitivity run 39 | # format: list of ['long_name', reference value, 'short_name'] 40 | # attention: for integers, the values will be rounded to the nearest integer 41 | # and for default integers smaller than 1/sensitivity, the sensitivity will 42 | # be studied taking default +/ 1 43 | pars = [ 44 | [r'building_forGrid.heaSys.betaFactorHeatPump',0.8, 'beta'], 45 | [r'building_forGrid.heaSys.volumeTank', 0.25, 'vol_tank'], 46 | # [r'building_forGrid.heaSys.HPControl.dTSafetyTop', 3.0, 'dTSafetyTop'], 47 | [u'building_forGrid.heaSys.timeFilter', 43200.0, 'timeFilter'], 48 | [u'building_forGrid.heaSys.dTSupRetNom', 5, 'dTSupRetNom'], 49 | [u'building_forGrid.heaSys.FHChars[1].T', 0.2, 'FHChars_T1'], 50 | [u'building_forGrid.heaSys.FHChars[2].T', 0.2, 'FHChars_T2'] 51 | ] 52 | # Specify the variables required for the analysis 53 | variables = dict(TMixed = u'building_forGrid.heaSys.TDHW', 54 | mDHW = u'building_forGrid.heaSys.mDHW', 55 | PEl = u'building_forGrid.heaSys.P', 56 | QHP = u'building_forGrid.heaSys.QHP', 57 | QHeatTotal = 'building_forGrid.heaSys.QHeatTotal') 58 | 59 | """ 60 | Remark: the x- and y-axis for the plots can be defined in the 'analyse_results' 61 | section (you can search for to_plot_x to get there). 62 | """ 63 | 64 | ############################################################################### 65 | os.chdir(os.path.abspath(work_dir)) 66 | 67 | if setup_and_run: 68 | if os.path.exists(os.path.join(work_dir, 'results_pr')): 69 | remove_results = raw_input('Remove the results in results_pr ? (y/n) \n ==> ') 70 | if remove_results == 'y' or remove_results == 'Y': 71 | rmtree(os.path.join(work_dir, 'results_pr')) 72 | else: 73 | raise NotImplementedError("Remove the results_pr folder first !") 74 | 75 | # first we must make a dictionary of the parameteric we want to do 76 | # and we add the parameters and their values we want to run 77 | pars_to_run = {} 78 | for par in pars: 79 | pars_to_run[par[0]] = par[1] 80 | 81 | # now we set everything ready for parallel python, the return consists of a 82 | # list of cd-paths where all sub-sets are located as for parallel python 83 | sub_dir = pymosim.set_sensitivity_run(work_dir, pars_to_run) 84 | 85 | # initialise parallel python 86 | ppservers=() 87 | job_server = pp.Server(ppservers = ppservers, ncpus=ncpus) 88 | # define the inputs and start the simulations 89 | inputs = tuple(sub_dir) 90 | jobs = [(input, job_server.submit(pymosim.start_parametric_run, args = (input,), modules = ("subprocess","os"))) for input in inputs] 91 | job_server.wait() 92 | job_server.destroy() 93 | 94 | pymosim.close_parametric_run(work_dir, sub_dir) 95 | 96 | ############################################################################### 97 | if get_results: 98 | print 'Getting results for:' 99 | # make a list of logfiles 100 | os.chdir(os.path.join(work_dir, 'results_pr')) 101 | fileList = os.listdir(os.getcwd()) 102 | log_files = [f for f in fileList if f.find('dslog_run_') > -1] 103 | # mat_files = [f for f in fileList if f.find('result_run_') > -1] 104 | 105 | # results is list with dictionaries containing all useful info from the runs 106 | results = [] 107 | 108 | # first, get info from the log files 109 | for l in log_files: 110 | summary = pymosim.analyse_log(l) 111 | summary['mat_file'] = l.replace('.txt','.mat').replace('dslog', 'result') 112 | results.append(summary) 113 | # suc6 = [l['successful'] for l in logs] checked, all are successful! 114 | 115 | # second, get the used parameters and simulation results 116 | 117 | # paramaeteres = contains short and long names of the parameters we need. 118 | # The data will be extracted from the .mat files and put in a dictionary 119 | # The short names will be the keys in that dictionary 120 | parameters = {} 121 | for par in pars: 122 | parameters[par[2]] = par[0] 123 | 124 | for r in results: 125 | print ''.join(['\t - ', r['mat_file']]) 126 | # r is the dictionary containing all results for this specific run 127 | sim = Simulation(r['mat_file']) 128 | # we add info to the dictionary: key = var, values = value for var 129 | for k,v in parameters.iteritems(): 130 | r[k] = sim.get_value(v) 131 | for k,v in variables.iteritems(): 132 | r[k] = sim.get_value(v) 133 | # we also get Time 134 | r['Time'] = sim.get_value('Time') 135 | 136 | ############################################################################### 137 | if analyse_results: 138 | print 'Analyzing results for:' 139 | for r in results: 140 | print ''.join(['\t - ', r['mat_file']]) 141 | # DHW analysis 142 | TDHW_too_low = np.nonzero(r['TMixed'] < (273.15+45.))[0] 143 | m_flow_discomfort = r['mDHW'][TDHW_too_low] 144 | m_flow_discomfort_weighted = (r['mDHW'] * (273.15+45.-r['TMixed']))[TDHW_too_low] 145 | DHW_discomfort = sum(m_flow_discomfort)/sum(r['mDHW']) 146 | dT_discomfort = sum(m_flow_discomfort_weighted)/sum(m_flow_discomfort) 147 | r['DHW_discomfort'] = DHW_discomfort 148 | r['dT_discomfort'] = dT_discomfort 149 | r['TDHW_min'] = min(r['TMixed']) 150 | 151 | # Heating analysis 152 | # this could be more efficient: getting the results should happen in the 153 | # previous section in order to avoid recreating sim objects 154 | total = 0 155 | sim = Simulation(r['mat_file']) 156 | for z in range(int(sim.get_value(u'building_forGrid.heaSys.n_C'))): 157 | var_name = ''.join(['discomfort_zone_', str(z+1)]) 158 | dt = sim.get_value(''.join([u'building_forGrid.TopAsked[', str(z+1), u']'])) \ 159 | - sim.get_value(''.join([u'building_forGrid.Top[', str(z+1), u']'])) 160 | dt[np.nonzero(dt<0)]=0 161 | dt_int = np.trapz(dt, r['Time'])/3600 # in Kh 162 | r[var_name] = dt_int.sum() 163 | total += r[var_name] 164 | r['Heating_discomfort'] = total 165 | 166 | # Energy consumption and SPF 167 | r['PEl_yr'] = np.trapz(r['PEl'], r['Time'])/1e6 # MJ 168 | r['QHeatTotal_yr'] = np.trapz(r['QHeatTotal'], r['Time'])/1e6 # MJ 169 | r['QHP_yr'] = np.trapz(r['QHP'], r['Time'])/1e6 # MJ 170 | r['SPF_HP'] = r['QHP_yr'] / r['PEl_yr'] 171 | r['SPF_system'] = r['QHeatTotal_yr'] / r['PEl_yr'] 172 | 173 | # Make the graph(s) ######################################################## 174 | 175 | # make numpy arrays with the values of the things we'd like to plot 176 | # these arrays are named according to the variable they contain!! 177 | # to make the script safe, the arrays are added as attributes to a dummy 178 | # class called arrays. 179 | 180 | class Dummy(): 181 | pass 182 | arrays = Dummy() 183 | 184 | # x and y axis of the plots 185 | to_plot_x = ['DHW_discomfort', 'Heating_discomfort', 'CPU_time'] 186 | to_plot_y = ['PEl_yr', 'SPF_system'] 187 | 188 | to_plot = [] 189 | to_plot.extend(to_plot_x) 190 | to_plot.extend(to_plot_y) 191 | # beside results, we also need all parameters 192 | to_plot.extend(parameters.keys()) 193 | 194 | for k in to_plot: 195 | ar = np.array([np.double(d[k]) for d in results]) 196 | exec(''.join(['arrays.', k, '= ar'])) 197 | 198 | # setting the colors, 1 color for each parameter 199 | cm = plt.cm.jet 200 | colors = [cm.__call__(f) for f in np.arange(0,1,1./len(parameters))] 201 | 202 | plots_to_make = [(x,y) for x in to_plot_x for y in to_plot_y] 203 | for x,y in plots_to_make: 204 | # make 1 plot for each x-axis / y-axis combination 205 | array_x = eval(''.join(['arrays.', x])) 206 | array_y = eval(''.join(['arrays.', y])) 207 | fig = plt.figure() 208 | ax = plt.subplot(111) 209 | 210 | color_index = 0 211 | for k, v in parameters.items(): 212 | c = colors[color_index] 213 | # plot the sensitivity results for each parameter 214 | # 1. get x and y values 215 | par_values = eval(''.join(['arrays.', k])) 216 | # index should become a list with 3 indices pointing to 217 | # the lower value, ref value and upper value for the considered parameter 218 | try: 219 | index = [np.nonzero(par_values < (1-sensitivity/2)*pars_to_run[v])[0][0]] 220 | except(IndexError): 221 | index = [0] 222 | index.append(0) 223 | try: 224 | index.append(np.nonzero(par_values > (1+sensitivity/2)*pars_to_run[v])[0][0]) 225 | except(IndexError): 226 | index.append(0) 227 | 228 | array_x_sel = array_x[index] 229 | array_y_sel = array_y[index] 230 | 231 | # 2. Plot lower, ref and upper as a colored line, no markers 232 | ax.plot(array_x_sel, array_y_sel, color=('0.8')) 233 | 234 | # 3. Plot lower as triangle down and upper as triangle up 235 | ax.plot(array_x_sel[0], array_y_sel[0], linestyle = 'None', 236 | marker = 'v', markersize = 13, 237 | markeredgecolor = c, markerfacecolor = c, label = k) 238 | ax.plot(array_x_sel[2], array_y_sel[2], linestyle = 'None', 239 | marker = '^', markersize = 13, markerfacecolor = c, 240 | markeredgecolor = c) 241 | 242 | color_index += 1 243 | 244 | # 4. Plot the ref? Not needed maybe: = crossing of the lines 245 | ylim = ax.get_ylim() 246 | ax.set_ylim(top = ylim[1] + 1.2 * (ylim[1] - ylim[0])) 247 | 248 | leg = ax.legend(loc = 'upper right') 249 | for t in leg.get_texts(): 250 | t.set_fontsize('small') # the legend text fontsize 251 | ax.set_xlabel(x) 252 | ax.set_ylabel(y) 253 | fig.suptitle(''.join([y, ' versus ', x])) 254 | 255 | # free the results_pr directory 256 | os.chdir(os.path.abspath(work_dir)) -------------------------------------------------------------------------------- /tests/Array.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/Array.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_A.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_A.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_B.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_C.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_C.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_D.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_E.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_E.mat -------------------------------------------------------------------------------- /tests/LinkedCapacities_F.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/LinkedCapacities_F.mat -------------------------------------------------------------------------------- /tests/PythonTestPackage.mo: -------------------------------------------------------------------------------- 1 | within ; 2 | package PythonTestPackage 3 | "Package used to generate .mat files for testing the python simman module" 4 | 5 | connector HeatPort 6 | Modelica.SIunits.Temperature T "potential"; 7 | flow Modelica.SIunits.HeatFlowRate Q_flow "flow variable"; 8 | 9 | /* Modelica.SIunits.pressure p; 10 | flow Modelica.SIunits.MassFlowrate m_flow; 11 | */ 12 | annotation (Icon); 13 | end HeatPort; 14 | 15 | model Resistor 16 | HeatPort heatPort_a; 17 | HeatPort heatPort_b; 18 | parameter Modelica.SIunits.ThermalResistance R=1; 19 | 20 | equation 21 | heatPort_a.Q_flow=(heatPort_a.T-heatPort_b.T)/R; 22 | heatPort_a.Q_flow+heatPort_b.Q_flow=0; 23 | end Resistor; 24 | 25 | model Capacity 26 | HeatPort heatPort; 27 | parameter Modelica.SIunits.HeatCapacity C=800; 28 | Modelica.SIunits.Temperature T; 29 | 30 | equation 31 | T=heatPort.T; 32 | C*der(T)=heatPort.Q_flow; 33 | 34 | end Capacity; 35 | 36 | model LinkedCapacities 37 | Capacity c1(T(start = 400),C=600); 38 | Capacity c2(T(start = 350),C=1000); 39 | Resistor r(R=3); 40 | 41 | equation 42 | connect(c1.heatPort,r.heatPort_a); 43 | connect(c2.heatPort,r.heatPort_b); 44 | 45 | /* 46 | connect-statement : 47 | - potentials are set equal, 48 | - Kirchoff to "flow" variables 49 | */ 50 | 51 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 52 | end LinkedCapacities; 53 | 54 | model Array "Test model to check array handling in python" 55 | 56 | parameter Integer n=4; 57 | parameter Real[n] cvalues={600,1000,400,600}; 58 | parameter Real[n] Tstarts={500,350,600,200}; 59 | Capacity[n] c(C=cvalues, T(start = Tstarts)); 60 | Resistor[n] r; 61 | 62 | /*Resistor[m,n,o] r; "3D matrix"*/ 63 | 64 | equation 65 | for i in 1:n loop 66 | connect(c[i].heatPort,r[i].heatPort_a); 67 | 68 | connect(r[1].heatPort_b,r[i].heatPort_b); 69 | end for; 70 | 71 | end Array; 72 | annotation (uses(Modelica(version="3.1"))); 73 | model LinkedCapacities_A 74 | Capacity c1(T(start = 400),C=800); 75 | Capacity c2(T(start = 350),C=1000); 76 | Resistor r(R=3); 77 | parameter String info_string = "Ref with changed c1.C"; 78 | 79 | equation 80 | connect(c1.heatPort,r.heatPort_a); 81 | connect(c2.heatPort,r.heatPort_b); 82 | 83 | /* 84 | connect-statement : 85 | - potentials are set equal, 86 | - Kirchoff to "flow" variables 87 | */ 88 | 89 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 90 | end LinkedCapacities_A; 91 | 92 | model LinkedCapacities_B 93 | Capacity c1(T(start = 400),C=1000); 94 | Capacity c2(T(start = 350),C=1000); 95 | Resistor r(R=3); 96 | parameter String info_string = "Ref with changed c1.C"; 97 | 98 | equation 99 | connect(c1.heatPort,r.heatPort_a); 100 | connect(c2.heatPort,r.heatPort_b); 101 | 102 | /* 103 | connect-statement : 104 | - potentials are set equal, 105 | - Kirchoff to "flow" variables 106 | */ 107 | 108 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 109 | end LinkedCapacities_B; 110 | 111 | model LinkedCapacities_C 112 | Capacity c1(T(start = 400),C=600); 113 | Capacity c2(T(start = 350),C=1000); 114 | Resistor r(R=5.5); 115 | parameter String info_string = "Ref with changed r.R"; 116 | 117 | equation 118 | connect(c1.heatPort,r.heatPort_a); 119 | connect(c2.heatPort,r.heatPort_b); 120 | 121 | /* 122 | connect-statement : 123 | - potentials are set equal, 124 | - Kirchoff to "flow" variables 125 | */ 126 | 127 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 128 | end LinkedCapacities_C; 129 | 130 | model LinkedCapacities_D 131 | Capacity c1(T(start = 400),C=800); 132 | Capacity c2(T(start = 350),C=1000); 133 | Resistor r(R=5.5); 134 | parameter String info_string = "as A but changed r.R"; 135 | 136 | equation 137 | connect(c1.heatPort,r.heatPort_a); 138 | connect(c2.heatPort,r.heatPort_b); 139 | 140 | /* 141 | connect-statement : 142 | - potentials are set equal, 143 | - Kirchoff to "flow" variables 144 | */ 145 | 146 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 147 | end LinkedCapacities_D; 148 | 149 | model LinkedCapacities_E 150 | Capacity c1(T(start = 400),C=800); 151 | Capacity c2(T(start = 350),C=1000); 152 | Resistor r(R=8.15); 153 | parameter String info_string = "as A but changed r.R"; 154 | 155 | equation 156 | connect(c1.heatPort,r.heatPort_a); 157 | connect(c2.heatPort,r.heatPort_b); 158 | 159 | /* 160 | connect-statement : 161 | - potentials are set equal, 162 | - Kirchoff to "flow" variables 163 | */ 164 | 165 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 166 | end LinkedCapacities_E; 167 | 168 | model LinkedCapacities_D_TooShort 169 | Capacity c1(T(start = 400),C=800); 170 | Capacity c2(T(start = 350),C=1000); 171 | Resistor r(R=5.5); 172 | parameter String info_string = "as A but changed r.R"; 173 | 174 | equation 175 | connect(c1.heatPort,r.heatPort_a); 176 | connect(c2.heatPort,r.heatPort_b); 177 | 178 | /* 179 | connect-statement : 180 | - potentials are set equal, 181 | - Kirchoff to "flow" variables 182 | */ 183 | 184 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 185 | end LinkedCapacities_D_TooShort; 186 | 187 | model Array_Big 188 | "Test model to check array handling in python - big array and big .mat file" 189 | 190 | parameter Integer n=800; 191 | 192 | Capacity[n] c; 193 | Resistor[n] r; 194 | 195 | /*Resistor[m,n,o] r; "3D matrix"*/ 196 | 197 | equation 198 | for i in 1:n loop 199 | connect(c[i].heatPort,r[i].heatPort_a); 200 | 201 | connect(r[1].heatPort_b,r[i].heatPort_b); 202 | end for; 203 | 204 | end Array_Big; 205 | 206 | model LinkedCapacities_F 207 | Capacity c1(T(start = 400),C=800); 208 | Capacity c2(T(start = 350),C=1000); 209 | Resistor r(R = 3); 210 | parameter String info_string = "as A with additional parameter"; 211 | parameter Real newParameter = 5 "a new parameter added here"; 212 | Real newVariable(start = 25); 213 | 214 | equation 215 | newVariable = 25 - time; 216 | connect(c1.heatPort,r.heatPort_a); 217 | connect(c2.heatPort,r.heatPort_b); 218 | 219 | /* 220 | connect-statement : 221 | - potentials are set equal, 222 | - Kirchoff to "flow" variables 223 | */ 224 | 225 | annotation (experiment(StopTime=10000, Interval=200), experimentSetupOutput); 226 | end LinkedCapacities_F; 227 | end PythonTestPackage; 228 | -------------------------------------------------------------------------------- /tests/ResultFileTxtFormat.txt: -------------------------------------------------------------------------------- 1 | #1 2 | char Aclass(3,11) 3 | Atrajectory 4 | 1.1 5 | 6 | char name(46,32) 7 | time 8 | building.RC.rWal 9 | building.RC.cZon 10 | building.RC.capZon.C 11 | building.RC.resWal.G 12 | building.RC.capZon.der(T) 13 | building.RC.capZon.T 14 | building.hvac.heatPortEmb.T 15 | building.hvac.heatPortRad.T 16 | building.RC.resWal.port_b.T 17 | building.RC.heatPortRad.T 18 | building.RC.heatPortEmb.T 19 | building.hvac.TZon 20 | building.RC.heatPortCon.T 21 | building.RC.capZon.port.T 22 | building.RC.senTZon.port.T 23 | building.RC.senTZon.T 24 | building.RC.TZon 25 | building.RC.heatPortSol.T 26 | building.hvac.heatPortCon.T 27 | TAmb 28 | building.TAmb 29 | building.RC.resWal.port_a.T 30 | building.TAmb2HeaPor.port.T 31 | building.RC.heatPortAmb.T 32 | building.TAmb2HeaPor.T 33 | QHea 34 | building.hvac.QHea 35 | building.hvac.heatPortCon.Q_flow 36 | building.RC.heatPortCon.Q_flow 37 | building.RC.capZon.der_T 38 | building.RC.capZon.port.Q_flow 39 | building.RC.senTZon.port.Q_flow 40 | building.RC.resWal.dT 41 | building.RC.heatPortAmb.Q_flow 42 | building.RC.resWal.port_b.Q_flow 43 | building.TAmb2HeaPor.port.Q_flow 44 | building.RC.resWal.port_a.Q_flow 45 | building.RC.resWal.Q_flow 46 | building.RC.heatPortSol.Q_flow 47 | building.RC.heatPortRad.Q_flow 48 | building.hvac.heatPortRad.Q_flow 49 | building.RC.heatPortEmb.Q_flow 50 | building.hvac.heatPortEmb.Q_flow 51 | _test_runtime_options 52 | _test_runtime_options_2 53 | 54 | char description(46,68) 55 | Time in [s] 56 | Total thermal resistance of the walls, in K/W 57 | Thermal capacity of the zone 58 | Heat capacity of element (= cp*m) 59 | Constant thermal conductance of material 60 | 61 | Temperature of element 62 | Port temperature 63 | Port temperature 64 | Port temperature 65 | Port temperature 66 | Port temperature 67 | 68 | Port temperature 69 | Port temperature 70 | Port temperature 71 | 72 | 73 | Port temperature 74 | Port temperature 75 | 76 | 77 | Port temperature 78 | Port temperature 79 | Port temperature 80 | 81 | 82 | 83 | Heat flow rate (positive if flowing from outside into the component) 84 | Heat flow rate (positive if flowing from outside into the component) 85 | Time derivative of temperature (= der(T)) 86 | Heat flow rate (positive if flowing from outside into the component) 87 | Heat flow rate (positive if flowing from outside into the component) 88 | port_a.T - port_b.T 89 | Heat flow rate (positive if flowing from outside into the component) 90 | Heat flow rate (positive if flowing from outside into the component) 91 | Heat flow rate (positive if flowing from outside into the component) 92 | Heat flow rate (positive if flowing from outside into the component) 93 | Heat flow rate from port_a -> port_b 94 | Heat flow rate (positive if flowing from outside into the component) 95 | Heat flow rate (positive if flowing from outside into the component) 96 | Heat flow rate (positive if flowing from outside into the component) 97 | Heat flow rate (positive if flowing from outside into the component) 98 | Heat flow rate (positive if flowing from outside into the component) 99 | 100 | 101 | 102 | int dataInfo(46,4) 103 | 0 1 0 -1 # time 104 | 1 2 0 -1 # building.RC.rWal 105 | 1 3 0 -1 # building.RC.cZon 106 | 1 4 0 -1 # building.RC.capZon.C 107 | 1 5 0 -1 # building.RC.resWal.G 108 | 2 2 0 -1 # building.RC.capZon.der(T) 109 | 2 3 0 -1 # building.RC.capZon.T 110 | 2 3 0 -1 # building.hvac.heatPortEmb.T 111 | 2 3 0 -1 # building.hvac.heatPortRad.T 112 | 2 3 0 -1 # building.RC.resWal.port_b.T 113 | 2 3 0 -1 # building.RC.heatPortRad.T 114 | 2 3 0 -1 # building.RC.heatPortEmb.T 115 | 2 3 0 -1 # building.hvac.TZon 116 | 2 3 0 -1 # building.RC.heatPortCon.T 117 | 2 3 0 -1 # building.RC.capZon.port.T 118 | 2 3 0 -1 # building.RC.senTZon.port.T 119 | 2 3 0 -1 # building.RC.senTZon.T 120 | 2 3 0 -1 # building.RC.TZon 121 | 2 3 0 -1 # building.RC.heatPortSol.T 122 | 2 3 0 -1 # building.hvac.heatPortCon.T 123 | 2 4 0 -1 # TAmb 124 | 2 4 0 -1 # building.TAmb 125 | 2 4 0 -1 # building.RC.resWal.port_a.T 126 | 2 4 0 -1 # building.TAmb2HeaPor.port.T 127 | 2 4 0 -1 # building.RC.heatPortAmb.T 128 | 2 4 0 -1 # building.TAmb2HeaPor.T 129 | 2 5 0 -1 # QHea 130 | 2 5 0 -1 # building.hvac.QHea 131 | 2 -5 0 -1 # building.hvac.heatPortCon.Q_flow 132 | 2 5 0 -1 # building.RC.heatPortCon.Q_flow 133 | 2 6 0 -1 # building.RC.capZon.der_T 134 | 2 7 0 -1 # building.RC.capZon.port.Q_flow 135 | 2 8 0 -1 # building.RC.senTZon.port.Q_flow 136 | 2 9 0 -1 # building.RC.resWal.dT 137 | 2 10 0 -1 # building.RC.heatPortAmb.Q_flow 138 | 2 -10 0 -1 # building.RC.resWal.port_b.Q_flow 139 | 2 -10 0 -1 # building.TAmb2HeaPor.port.Q_flow 140 | 2 10 0 -1 # building.RC.resWal.port_a.Q_flow 141 | 2 10 0 -1 # building.RC.resWal.Q_flow 142 | 2 11 0 -1 # building.RC.heatPortSol.Q_flow 143 | 2 12 0 -1 # building.RC.heatPortRad.Q_flow 144 | 2 -12 0 -1 # building.hvac.heatPortRad.Q_flow 145 | 2 13 0 -1 # building.RC.heatPortEmb.Q_flow 146 | 2 -13 0 -1 # building.hvac.heatPortEmb.Q_flow 147 | 1 6 0 -1 # _test_runtime_options 148 | 1 7 0 -1 # _test_runtime_options_2 149 | 150 | float data_1(2,7) 151 | 0.00000000000000E+00 3.26852000000000E-03 1.32947000000000E+06 1.32947000000000E+06 3.05948869824875E+02 0.00000000000000E+00 0.00000000000000E+00 152 | 6.04800000000000E+05 3.26852000000000E-03 1.32947000000000E+06 1.32947000000000E+06 3.05948869824875E+02 0.00000000000000E+00 0.00000000000000E+00 153 | 154 | float data_2(11,13) 155 | 0.00000000000000E+00 -2.33580376294499E-03 2.93150000000000E+02 2.83000000000000E+02 0.00000000000000E+00 -2.33580376294499E-03 -3.10538102872247E+03 0.00000000000000E+00 -1.01500000000000E+01 -3.10538102872247E+03 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 156 | 6.04800000000000E+04 -3.21892364569270E-04 2.76831184916348E+02 2.75432434065695E+02 0.00000000000000E+00 -3.21892364569270E-04 -4.27946241923907E+02 0.00000000000000E+00 -1.39875085065313E+00 -4.27946241923907E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 157 | 1.20960000000000E+05 -3.30567899510822E-04 2.89099191213777E+02 2.87662741699797E+02 0.00000000000000E+00 -3.30567899510822E-04 -4.39480105362653E+02 0.00000000000000E+00 -1.43644951397994E+00 -4.39480105362653E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 158 | 1.81440000000000E+05 5.90151037252667E-04 2.88366819804831E+02 2.87662741699797E+02 1.00000000000000E+03 5.90151037252667E-04 7.84588099496304E+02 0.00000000000000E+00 -7.04078105034341E-01 -2.15411900503696E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 159 | 2.41920000000000E+05 4.69779799222843E-06 2.78680540257661E+02 2.75432434065695E+02 1.00000000000000E+03 4.69779799222843E-06 6.24558149672794E+00 0.00000000000000E+00 -3.24810619196631E+00 -9.93754418503272E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 160 | 3.02400000000000E+05 -5.25773612929220E-04 2.88553216281379E+02 2.83000000000000E+02 1.00000000000000E+03 -5.25773612929220E-04 -6.99000245181011E+02 0.00000000000000E+00 -5.55321628137904E+00 -1.69900024518101E+03 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 161 | 3.62880000000000E+05 3.22000070961302E-04 2.92436867056373E+02 2.90567565934305E+02 1.00000000000000E+03 3.22000070961302E-04 4.28089434340922E+02 0.00000000000000E+00 -1.86930112206801E+00 -5.71910565659078E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 162 | 4.23360000000000E+05 3.30539129401615E-04 2.80169453803835E+02 2.78337258300203E+02 1.00000000000000E+03 3.30539129401615E-04 4.39441856365566E+02 0.00000000000000E+00 -1.83219550363202E+00 -5.60558143634434E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 163 | 4.83840000000000E+05 -5.20060420151845E-04 2.83865648477776E+02 2.78337258300203E+02 1.00000000000000E+03 -5.20060420151845E-04 -6.91404726779273E+02 0.00000000000000E+00 -5.52839017757259E+00 -1.69140472677927E+03 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 164 | 5.44320000000000E+05 -4.68989076892119E-06 2.93856465382296E+02 2.90567565934305E+02 1.00000000000000E+03 -4.68989076892119E-06 -6.23506908055765E+00 0.00000000000000E+00 -3.28889944799118E+00 -1.00623506908056E+03 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 165 | 6.04800000000000E+05 5.25756034378016E-04 2.83983900104445E+02 2.83000000000000E+02 1.00000000000000E+03 5.25756034378016E-04 6.98976875024542E+02 0.00000000000000E+00 -9.83900104444785E-01 -3.01023124975458E+02 0.00000000000000E+00 -0.00000000000000E+00 -0.00000000000000E+00 166 | -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/Array.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/Array.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/EmptyMatFile.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/EmptyMatFile.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_A.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_A.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_B.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_B.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_C.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_C.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_D.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_D.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_D_TooShort.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_D_TooShort.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_E.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_E.mat -------------------------------------------------------------------------------- /tests/SubfolderWithCrappyFiles/LinkedCapacities_F.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/SubfolderWithCrappyFiles/LinkedCapacities_F.mat -------------------------------------------------------------------------------- /tests/TestSet2/reswithCPUtime.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saroele/awesim/368b5a97417019be03b83685cdb0de889777ac42/tests/TestSet2/reswithCPUtime.mat --------------------------------------------------------------------------------