increment
- class czmtestkit.py_modules.increment
Bases:
objectRead and store matrices written to Abaqus/CAE
.msgfile.- Attributes
increment.step_time (float): Step time fraction of the increment [optional].
increment.start (int): Line number corresponding to the first line of the increment.
increment.stop (int): Line number corresponding to the last line of the increment.
increment.fileName (str): path to the .msg file including the file name and extension.
increment.outInst (list):
dataobjects with matrix/arrays from the .msg file corresponding to the increment found using theincrement.find_lineNumbers()andincrement.find_data()methods.increment.data (dict): Data from the increment organized into a dict. Keys of the dict indicate the keyword used to find the data and the Values of the dict carry lists of corresponding
dataobjects.
Example
If the following variables are written to
filename.msgfile:17 VarKey1 = 1.000000 2.00000020 VarKey2 = 1.000000 2.000000 3.000000 21 4.000000
24 VarKey1 = 1.100000 2.10000027 VarKey2 = 1.100000 2.100000 3.100000 28 4.100000
50 VarKey1 = 1.200000 2.20000053 VarKey2 = 1.200000 2.200000 3.200000 54 4.200000
57 VarKey1 = 1.300000 2.30000060 VarKey2 = 1.300000 2.300000 3.300000 61 4.300000
where VarKey1 is the keyword for a variable Var1 which is a column matrix and VarKey2 represents a square matrix Var2.
\[ \begin{align}\begin{aligned}\begin{split}Var1 &= \left[ \begin{matrix} \# \\ \# \end{matrix} \right]\end{split}\\\begin{split}Var2 &= \left[ \begin{matrix} \# & \# \\ \# & \# \end{matrix} \right]\end{split}\end{aligned}\end{align} \]To fetch these variables printed between lines 22 and 58, initialize an
incrementclass instance.incInst = increment() incInst.fileName = "filename.msg" incInst.start = 22 incInst.stop = 58
Further, find Var1 using
VarKey1keyword and create a list ofdataclass instances of the three occurances. Here, the matrix elements for Var1 are printed on a single line and the matrix is a column matrix with two rows, so use execute theincrement.find_lineNumbers()as follows:incInst.find_lineNumbers("VarKey1", 1, (2,1))
This appends
dataclass instance of the three occurances ofVarKey1to increment.outInst for example, details of the 2nd occurance can be extracted as follows:print(incInst.outInst[1].type, incInst.outInst[1].start, incInst.outInst[1].stop, incInst.outInst[1].shape)
Output
VarKey1 50 50 (2,1)
Append the occurances of the square matrix Var2 of dimensions 2x2 printed to two consecutive lines to the increment.outInst list.
incInst.find_lineNumbers("VarKey2", 2, (2,2))
This appends
dataclass instance of the two occurances ofVarKey2to increment.outInst for example, details of the 1st occurance of Var2 which is 4th in the list can be extracted as follows:print(incInst.outInst[3].type, incInst.outInst[3].start, incInst.outInst[3].stop, incInst.outInst[3].shape)
Output
VarKey2 27 28 (2,2)
Finally fetch the values corresponding to the five selected matrices using
increment.find_data().incInst.find_data() # First occurence of VarKey2 print(incInst.outInst[3].value) print(incInst.data['VarKey2'][0].value) # Third occurence of VarKey1 print(incInst.outInst[2].value) print(incInst.data['VarKey1'][2].value)
Output
[[1.100000, 3.100000], [2.100000, 4.100000]] [[1.100000, 3.100000], [2.100000, 4.100000]] [[1.300000], [2.300000]] [[1.300000], [2.300000]]
Methods Summary
Fetch values of the matrices/arrays corresponding to
dataclass instances in increment.outInst.find_lineNumbers(key, length, shape)Find a keyword and create
dataclass instance for each occurance of the keyword between increment.start and increment.stop in the.msgfile. Thedatainstances are appended toincrement.outInstattribute. (Seeincrementclass for an example.)Methods Documentation
- find_data()
Fetch values of the matrices/arrays corresponding to
dataclass instances in increment.outInst. (Seeincrementclass for an example.)Note
This funciton only fetches and reshapes the values of
datainstances.datainstances must have already been defined usingincrement.find_lineNumbers()method before executing this method.
- find_lineNumbers(key, length, shape)
Find a keyword and create
dataclass instance for each occurance of the keyword between increment.start and increment.stop in the.msgfile. Thedatainstances are appended toincrement.outInstattribute. (Seeincrementclass for an example.)- Parameters
key (str): Keyword to find the matrix/array of interest. Ideally, this should indicate the vairable name of the matrix/array printed to the .msg file.
length (int): Number of lines the matrix extends to, starting from the line containing the Keyword.
shape (tuple): Shape of the matrix.
shape[0] (int): number of rows.
shape[1] (int): number of columns.
Tip
This method can be executed multiple times with different keywords. Since the
dataclass instances store the keywords and the line numbers, the values can be systematically retrived. Seeincrement.find_data().Note
This funciton only creates
datainstances and finds line numbers corresponding to required matrix.data.findValue()has to be executed to fetch the actual values. Useincrement.find_data()to do this automatically for all the instances inincrement.outInst.Warning
incrementattributes increment.type, increment.start, and increment.stop must be defined to execute theincrement.find_lineNumbers()method.