rdmax 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rdmax/__init__.py +18 -0
- rdmax/_common.py +31 -0
- rdmax/compat.py +20 -0
- rdmax/license.py +36 -0
- rdmax/mfn.py +357 -0
- rdmax/modeling.py +1674 -0
- rdmax/post.py +479 -0
- rdmax/rplt.py +320 -0
- rdmax/start.py +83 -0
- rdmax/textfile.py +302 -0
- rdmax/utils.py +89 -0
- rdmax-0.1.0.dist-info/METADATA +76 -0
- rdmax-0.1.0.dist-info/RECORD +16 -0
- rdmax-0.1.0.dist-info/WHEEL +5 -0
- rdmax-0.1.0.dist-info/licenses/LICENSE.txt +21 -0
- rdmax-0.1.0.dist-info/top_level.txt +1 -0
rdmax/post.py
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"""RecurDyn post-processing helpers (split from RDFunctions.py)."""
|
|
2
|
+
|
|
3
|
+
from rdmax._common import * # noqa: F401,F403
|
|
4
|
+
from rdmax.utils import ColorSeries, str_to_liststr
|
|
5
|
+
from rdmax.rplt import RpltReader
|
|
6
|
+
|
|
7
|
+
__all__ = ['RecurDynPost', 'AnalysisResponse', 'MSG_LEGEND_L23', 'MSG_LEGEND_L21', 'MSG_LEGEND_EXT', 'MSG_LEGEND_STATIC', 'Post']
|
|
8
|
+
|
|
9
|
+
class RecurDynPost:
|
|
10
|
+
def __init__(self, ver, plot_name, modelname=None, clear_pages=False, clear_rplts=False):
|
|
11
|
+
|
|
12
|
+
plot = str(Path(plot_name).name)
|
|
13
|
+
self.application = IApplication(dispatch_recurdyn(ver, True, 300).RecurDynApplication)
|
|
14
|
+
|
|
15
|
+
# if modelname is not None and self.application.GetModelDocument(modelname) is not None:
|
|
16
|
+
# if self.application.GetPlotDocument(plot):
|
|
17
|
+
# self.application.ClosePlotDocument(self.application.GetPlotDocument(plot))
|
|
18
|
+
# print("Active modeldocument: " + modelname)
|
|
19
|
+
# modeldocument = self.application.GetModelDocument(modelname)
|
|
20
|
+
# self.plotDocument = modeldocument.CreatePlotDocument(PlotDocType.WithRPLT)
|
|
21
|
+
# self.plotDocument.Name = plot
|
|
22
|
+
# print(self.plotDocument.GetImportedFilePathList())
|
|
23
|
+
# quit()
|
|
24
|
+
|
|
25
|
+
self.plotDocument = self.application.GetPlotDocument(plot)
|
|
26
|
+
print(plot + ' is activated')
|
|
27
|
+
if self.plotDocument is None:
|
|
28
|
+
if Path(plot_name).is_file():
|
|
29
|
+
self.plotDocument = self.application.OpenPlotDocument(plot_name)
|
|
30
|
+
self.application.PrintMessage(plot + ' is loaded')
|
|
31
|
+
print(plot + ' is loaded')
|
|
32
|
+
else:
|
|
33
|
+
self.plotDocument = self.application.NewPlotDocument(plot_name)
|
|
34
|
+
# plotDocument.FileSave(plotDocument.Name + '.plot', True)
|
|
35
|
+
self.application.PrintMessage(plot_name + ' is created')
|
|
36
|
+
print(plot + ' is created')
|
|
37
|
+
self.plotDocument.Activate()
|
|
38
|
+
if clear_pages:
|
|
39
|
+
self.ClearPageAll()
|
|
40
|
+
if clear_rplts:
|
|
41
|
+
self.ClearRpltAll()
|
|
42
|
+
|
|
43
|
+
def ClearRpltAll(self):
|
|
44
|
+
for i in range(self.plotDocument.ImportedFileCount):
|
|
45
|
+
self.plotDocument.DeleteRPLT(0)
|
|
46
|
+
|
|
47
|
+
def ClearPageAll(self):
|
|
48
|
+
if self.plotDocument is None: return
|
|
49
|
+
|
|
50
|
+
npage = self.plotDocument.GetPageCount() - 1
|
|
51
|
+
for i in range(npage):
|
|
52
|
+
self.plotDocument.DeletePage(0)
|
|
53
|
+
self.plotDocument.ClearActivePage()
|
|
54
|
+
|
|
55
|
+
def ImportRplt(self, rplt_name):
|
|
56
|
+
try:
|
|
57
|
+
self.plotDocument.ImportPlotDataFile(rplt_name)
|
|
58
|
+
except:
|
|
59
|
+
print("Invalid rplt path: " + rplt_name)
|
|
60
|
+
|
|
61
|
+
def DrawaPlot(self, x_data, y_data, lgds="", xlabel="time(sec)", ylabel="value", title="", time_zone=None,
|
|
62
|
+
scale_x=1.0, scale_y=1.0):
|
|
63
|
+
# Deal single x, y data case
|
|
64
|
+
if type(x_data) is str: x_data = [x_data]
|
|
65
|
+
if type(y_data) is str: y_data = [y_data]
|
|
66
|
+
if type(lgds) is str: lgds = [lgds]
|
|
67
|
+
if type(scale_x) is float: scale_x = [scale_x]
|
|
68
|
+
if type(scale_y) is float: scale_y = [scale_y]
|
|
69
|
+
# Deal single legend case
|
|
70
|
+
legent_out = True
|
|
71
|
+
if len(lgds) == 1:
|
|
72
|
+
lgds = [lgds[i] for i, y_str in enumerate(y_data)]
|
|
73
|
+
legent_out = False
|
|
74
|
+
# Deal scale input case
|
|
75
|
+
if len(scale_x) == 1:
|
|
76
|
+
scale_x = np.full(len(x_data), scale_x)
|
|
77
|
+
if len(scale_y) == 1:
|
|
78
|
+
scale_y = np.full(len(y_data), scale_y)
|
|
79
|
+
# Check singularity
|
|
80
|
+
if len(x_data) != len(scale_x):
|
|
81
|
+
print('x data and scale is not match')
|
|
82
|
+
return
|
|
83
|
+
if len(y_data) is not len(y_data):
|
|
84
|
+
print('y data and scale is not match')
|
|
85
|
+
return
|
|
86
|
+
if len(x_data) is not len(y_data):
|
|
87
|
+
print('x y data is not match')
|
|
88
|
+
return
|
|
89
|
+
# Add page
|
|
90
|
+
if self.plotDocument.GetPageCount() == 1 and self.plotDocument.ActiveChartControl.SeriesCount == 0:
|
|
91
|
+
pass
|
|
92
|
+
else:
|
|
93
|
+
self.plotDocument.AddPage()
|
|
94
|
+
# Set page name
|
|
95
|
+
self.plotDocument.SetPageName(self.plotDocument.GetPageCount() - 1, title)
|
|
96
|
+
# Calc min. max.
|
|
97
|
+
xmin = 1.0e100
|
|
98
|
+
xmax = -1.0e100
|
|
99
|
+
ymin = 1.0e100
|
|
100
|
+
ymax = -1.0e100
|
|
101
|
+
|
|
102
|
+
def SnEn(data_name, tzone):
|
|
103
|
+
time = np.array(self.plotDocument.GetPlotData(data_name.split('/')[0] + '/TIME'))
|
|
104
|
+
sn = 0
|
|
105
|
+
en = len(time)
|
|
106
|
+
if tzone is None:
|
|
107
|
+
return sn, en
|
|
108
|
+
for i, t in enumerate(time):
|
|
109
|
+
if t >= tzone[0]:
|
|
110
|
+
sn = i
|
|
111
|
+
break
|
|
112
|
+
for i, t in reversed(list(enumerate(time))):
|
|
113
|
+
if t <= tzone[1]:
|
|
114
|
+
en = i
|
|
115
|
+
break
|
|
116
|
+
return sn, en
|
|
117
|
+
|
|
118
|
+
# draw plots
|
|
119
|
+
data = []
|
|
120
|
+
for i, y_name in enumerate(y_data):
|
|
121
|
+
print("[ " + str(x_data[i]) + " ]―[ " + str(y_data[i]) + " ]")
|
|
122
|
+
sn, en = SnEn(x_data[i], time_zone)
|
|
123
|
+
x = np.array(self.plotDocument.GetPlotData(x_data[i])[sn:en]) * scale_x[i]
|
|
124
|
+
sn, en = SnEn(y_data[i], time_zone)
|
|
125
|
+
y = np.array(self.plotDocument.GetPlotData(y_data[i])[sn:en]) * scale_y[i]
|
|
126
|
+
xmin = min(xmin, np.min(x))
|
|
127
|
+
xmax = max(xmax, np.max(x))
|
|
128
|
+
ymin = min(ymin, np.min(y))
|
|
129
|
+
ymax = max(ymax, np.max(y))
|
|
130
|
+
self.plotDocument.DrawPlot(lgds[i], x, y)
|
|
131
|
+
self.plotDocument.ActiveChartControl.GetSeries(i).Color = Color.rgb_to_bgr(ColorSeries[i % 9])
|
|
132
|
+
data.append(np.vstack((x, y)))
|
|
133
|
+
self.plotDocument.ActiveChartControl.AxisX.Title.Text = xlabel
|
|
134
|
+
self.plotDocument.ActiveChartControl.AxisY.Title.Text = ylabel
|
|
135
|
+
self.plotDocument.ActiveChartControl.Title.Text = title
|
|
136
|
+
# Setup range
|
|
137
|
+
margin = 0.05
|
|
138
|
+
xa = (xmax - xmin) * margin
|
|
139
|
+
ya = (ymax - ymin) * margin * 2
|
|
140
|
+
xodr = floor(np.log10(abs(xmax + 1e-12 - xmin))) - 1
|
|
141
|
+
yodr = floor(np.log10(abs(ymax + 1e-12 - ymin))) - 1
|
|
142
|
+
# print('Order :' + str(yodr))
|
|
143
|
+
# print('GAP : ' + str(ymax - ymin))
|
|
144
|
+
# print('GAP_rnd: ' + str(round(ymax - ymin, -yodr)))
|
|
145
|
+
# print('STEP : ' + str(round(ymax - ymin, -yodr)/10))
|
|
146
|
+
# print(str(ymin) + ' < y < ' + str(ymax))
|
|
147
|
+
# print(str(round(ymin, -yodr)) + ' < y < ' + str(round(ymax, -yodr)))
|
|
148
|
+
self.plotDocument.ActiveChartControl.AxisX.Min = round(xmin - xa, -xodr)
|
|
149
|
+
self.plotDocument.ActiveChartControl.AxisX.Max = round(xmax + xa, -xodr)
|
|
150
|
+
self.plotDocument.ActiveChartControl.AxisY.Min = round(ymin - ya, -yodr)
|
|
151
|
+
self.plotDocument.ActiveChartControl.AxisY.Max = round(ymax + ya, -yodr)
|
|
152
|
+
# if xodr <= 2.0:
|
|
153
|
+
# xodr = xodr
|
|
154
|
+
if yodr >= -1:
|
|
155
|
+
yodr = yodr - 1
|
|
156
|
+
# Setup steps
|
|
157
|
+
self.plotDocument.ActiveChartControl.AxisX.MajorTickStep = np.round((xmax - xmin), -xodr) / 10
|
|
158
|
+
# plotDocument.ActiveChartControl.AxisX.MinorTickStep = plotDocument.ActiveChartControl.AxisX.MajorTickStep/10
|
|
159
|
+
self.plotDocument.ActiveChartControl.AxisY.MajorTickStep = np.round((ymax - ymin), -yodr) / 5
|
|
160
|
+
# plotDocument.ActiveChartControl.AxisY.MinorTickStep = plotDocument.ActiveChartControl.AxisY.MajorTickStep/10
|
|
161
|
+
self.plotDocument.ActiveChartControl.AxisX.LabelsFormat.Decimals = max(0, -xodr)
|
|
162
|
+
self.plotDocument.ActiveChartControl.Axisy.LabelsFormat.Decimals = max(0, -yodr)
|
|
163
|
+
self.plotDocument.ActiveChartControl.BackColor = Color.rgb_to_bgr(Color.White)
|
|
164
|
+
# # print(plotDocument.ActiveChartControl.AxisY.MajorTickStep)
|
|
165
|
+
# # print(plotDocument.ActiveChartControl.Axisy.LabelsFormat.Decimals
|
|
166
|
+
# No legend setting
|
|
167
|
+
self.plotDocument.ActiveChartControl.LegendBox.Visible = legent_out
|
|
168
|
+
return data
|
|
169
|
+
|
|
170
|
+
def GetPlotData(self, data_names):
|
|
171
|
+
data = []
|
|
172
|
+
for i, data_name in enumerate(data_names):
|
|
173
|
+
y = np.array(self.plotDocument.GetPlotData(data_name))
|
|
174
|
+
data.append(y)
|
|
175
|
+
if len(data) == 1:
|
|
176
|
+
return data[0]
|
|
177
|
+
return data
|
|
178
|
+
|
|
179
|
+
def FFT(self, time_name, data_name, window=FFTWindowMethod.SquareType, n=None, ts=None, te=None):
|
|
180
|
+
self.DrawaPlot(time_name, data_name, lgds=["FFT"])
|
|
181
|
+
time = self.GetPlotData([time_name])
|
|
182
|
+
if n is None:
|
|
183
|
+
n = int(log2(len(time))) + 1
|
|
184
|
+
sn = 0
|
|
185
|
+
en = -1
|
|
186
|
+
if ts is not None:
|
|
187
|
+
for i, t in enumerate(time):
|
|
188
|
+
if ts < t:
|
|
189
|
+
sn = i
|
|
190
|
+
break
|
|
191
|
+
if te is not None:
|
|
192
|
+
for i, t in reversed(list(enumerate(time))):
|
|
193
|
+
if te > t:
|
|
194
|
+
en = i
|
|
195
|
+
break
|
|
196
|
+
self.plotDocument.FFTMagnitude(0, window, n, time[sn], time[en], True, True)
|
|
197
|
+
res = self.GetPlotData(["User Data/X:FFT-MAG(FFT)", "User Data/Y:FFT-MAG(FFT)"])
|
|
198
|
+
user_data_idx = len(self.plotDocument.GetImportedFilePathList()) - 1
|
|
199
|
+
self.plotDocument.DeleteRPLT(user_data_idx)
|
|
200
|
+
if self.plotDocument.GetPageCount() != 1:
|
|
201
|
+
self.plotDocument.DeletePage(self.plotDocument.GetPageCount() - 1)
|
|
202
|
+
return res
|
|
203
|
+
|
|
204
|
+
def PSD(self, time_name, data_name, window=FFTWindowMethod.SquareType, n=None, ts=None, te=None):
|
|
205
|
+
self.DrawaPlot(time_name, data_name, lgds=["PSD"])
|
|
206
|
+
time = self.GetPlotData([time_name])
|
|
207
|
+
if n is None:
|
|
208
|
+
n = int(log2(len(time))) + 1
|
|
209
|
+
sn = 0
|
|
210
|
+
en = -1
|
|
211
|
+
if ts is not None:
|
|
212
|
+
for i, t in enumerate(time):
|
|
213
|
+
if ts < t:
|
|
214
|
+
sn = i
|
|
215
|
+
break
|
|
216
|
+
if te is not None:
|
|
217
|
+
for i, t in reversed(list(enumerate(time))):
|
|
218
|
+
if te > t:
|
|
219
|
+
en = i
|
|
220
|
+
break
|
|
221
|
+
n = int(log2(len(time))) + 1
|
|
222
|
+
self.plotDocument.FFTPowerSpectralDensity2(0, window, n, time[sn], time[en], PSDType.PSDType_Density, False,
|
|
223
|
+
True)
|
|
224
|
+
res = self.GetPlotData(["User Data/X:FFT-PSD(PSD)", "User Data/Y:FFT-PSD(PSD)"])
|
|
225
|
+
user_data_idx = len(self.plotDocument.GetImportedFilePathList()) - 1
|
|
226
|
+
self.plotDocument.DeleteRPLT(user_data_idx)
|
|
227
|
+
if self.plotDocument.GetPageCount() != 1:
|
|
228
|
+
self.plotDocument.DeletePage(self.plotDocument.GetPageCount() - 1)
|
|
229
|
+
return res
|
|
230
|
+
|
|
231
|
+
def Filter(self, time_name, data_name, type=FilterOption.LowPass, order=2, freq1=0.1, freq2=100):
|
|
232
|
+
self.DrawaPlot(time_name, data_name, lgds=["Filter"])
|
|
233
|
+
self.plotDocument.FilterButterWorth(0, type, order, freq1, freq2, False, True)
|
|
234
|
+
x = self.GetPlotData(["User Data/X:BUTTERWORTH(Filter)"])
|
|
235
|
+
y = self.GetPlotData(["User Data/Y:BUTTERWORTH(Filter)"])
|
|
236
|
+
user_data_idx = len(self.plotDocument.GetImportedFilePathList()) - 1
|
|
237
|
+
self.plotDocument.DeleteRPLT(user_data_idx)
|
|
238
|
+
if self.plotDocument.GetPageCount() != 1:
|
|
239
|
+
self.plotDocument.DeletePage(self.plotDocument.GetPageCount() - 1)
|
|
240
|
+
return x, y
|
|
241
|
+
|
|
242
|
+
def Close(self):
|
|
243
|
+
self.application.ClosePlotDocument(self.plotDocument)
|
|
244
|
+
|
|
245
|
+
def Exit(self):
|
|
246
|
+
self.application.Exit()
|
|
247
|
+
time.sleep(1)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class AnalysisResponse:
|
|
251
|
+
def __init__(self, ver, rdyn_path=None):
|
|
252
|
+
print("[ RDFunctions version " + str(ver) + " ]")
|
|
253
|
+
self.rd_ver = ver
|
|
254
|
+
# set_rd_lib_path(self.rd_ver)
|
|
255
|
+
self.application = IApplication(dispatch_recurdyn(self.rd_ver, True, 300).RecurDynApplication)
|
|
256
|
+
# print("PNet Version: " + self.application.ProcessNetVersion)
|
|
257
|
+
if rdyn_path is None:
|
|
258
|
+
self.modelDocument = self.application.ActiveModelDocument
|
|
259
|
+
if self.modelDocument is None:
|
|
260
|
+
self.modelDocument = self.application.NewModelDocument('Model1')
|
|
261
|
+
else:
|
|
262
|
+
# rdyn_file_name = str(Path(rdyn_path).name) # rdyn file name only
|
|
263
|
+
rdyn_name = str(Path(rdyn_path).stem) # rdyn name only
|
|
264
|
+
self.modelDocument = self.application.GetModelDocument(rdyn_name)
|
|
265
|
+
# if self.modelDocument is None:
|
|
266
|
+
# if os.path.isfile(rdyn_file_name)
|
|
267
|
+
# self.modelDocument = self.application.GetModelDocument(rdyn_file_name)
|
|
268
|
+
if self.modelDocument is None:
|
|
269
|
+
if Path(rdyn_path).is_file():
|
|
270
|
+
self.modelDocument = self.application.OpenModelDocument(Path(rdyn_path).absolute())
|
|
271
|
+
self.application.PrintMessage(rdyn_name + ' is loaded')
|
|
272
|
+
print(rdyn_name + '.rdyn is loaded')
|
|
273
|
+
else:
|
|
274
|
+
self.modelDocument = self.application.NewModelDocument(rdyn_name)
|
|
275
|
+
self.modelDocument.FileSave(self.modelDocument.Name + '.rdyn', True)
|
|
276
|
+
self.application.PrintMessage(rdyn_name + ' is created')
|
|
277
|
+
print(rdyn_name + '.rdyn is created')
|
|
278
|
+
self.modelDocument = self.application.ActiveModelDocument
|
|
279
|
+
self.modelDocument = IModelDocument(self.modelDocument)
|
|
280
|
+
self.working_directory = self.modelDocument.GetPath(PathType.WorkingFolder)
|
|
281
|
+
self.model = ISubSystem(self.modelDocument.Model)
|
|
282
|
+
self.rdyn_path = self.modelDocument.GetPath(PathType.WorkingDocument)
|
|
283
|
+
|
|
284
|
+
def GetPlotData(self, EntityName="time", ContentsName=""):
|
|
285
|
+
if EntityName.upper().strip() == "TIME":
|
|
286
|
+
return self.modelDocument.GetPlotDataTime()
|
|
287
|
+
else:
|
|
288
|
+
return self.modelDocument.GetPlotData(self.model.GetEntity(EntityName), ContentsName)
|
|
289
|
+
|
|
290
|
+
def GetPIRiseTime(self, EntityName, stime=0.0, err_target=0.02):
|
|
291
|
+
# Rise time : Rise time 이란 시스템이 대략 특정 값에서 수렴하는 것으로 예측될 때, 그 근사값에 도달한 시간을 의미
|
|
292
|
+
time = self.modelDocument.GetPlotDataTime()
|
|
293
|
+
data = self.GetPlotData(EntityName)
|
|
294
|
+
for i in range(len(time)):
|
|
295
|
+
if time[i] >= stime and abs(data[i]) < abs(err_target):
|
|
296
|
+
return i, time[i], data[i]
|
|
297
|
+
return 0, time[0], data[0]
|
|
298
|
+
|
|
299
|
+
def GetPIPeakTime(self, EntityName, stime=0.0):
|
|
300
|
+
# Peak time : 시스템이 수렴할때 가장 높은 값이 존재 할 것이다. 그 값에 도달하는 시간을 Peak time 이라 한다.
|
|
301
|
+
time = self.modelDocument.GetPlotDataTime()
|
|
302
|
+
data = self.GetPlotData(EntityName)
|
|
303
|
+
maxn = 0
|
|
304
|
+
err_min = 0
|
|
305
|
+
for i in range(len(time)):
|
|
306
|
+
if time[i] >= stime and data[i] < err_min:
|
|
307
|
+
err_min = data[i]
|
|
308
|
+
maxn = i
|
|
309
|
+
return maxn, time[maxn], data[maxn]
|
|
310
|
+
|
|
311
|
+
def GetPISettlingTime(self, EntityName, stime=0.0, err_target=0.02):
|
|
312
|
+
# Settling time : Overshoot이 기준값과 1%, 2% 와 같이 목표값과 지정한 특정 값만큼 차이가 날때, 그 값에 도달하는 시간
|
|
313
|
+
time = self.modelDocument.GetPlotDataTime()
|
|
314
|
+
data = self.GetPlotData(EntityName)
|
|
315
|
+
n = len(time) - 1
|
|
316
|
+
for i in reversed(range(len(time))):
|
|
317
|
+
if time[i] >= stime and abs(data[i]) > abs(err_target):
|
|
318
|
+
n = i
|
|
319
|
+
break
|
|
320
|
+
return n, time[n], data[n]
|
|
321
|
+
|
|
322
|
+
def GetPIOvershoot(self, EntityName, stime=0.0):
|
|
323
|
+
time = self.modelDocument.GetPlotDataTime()
|
|
324
|
+
data = np.array(self.GetPlotData(EntityName))
|
|
325
|
+
maxn = len(time) - 1
|
|
326
|
+
err_min = 0
|
|
327
|
+
diff_pre = 0
|
|
328
|
+
for i in range(len(time) - 1):
|
|
329
|
+
if time[i] > stime:
|
|
330
|
+
diff = data[i + 1] - data[i]
|
|
331
|
+
if data[i] < err_min:
|
|
332
|
+
err_min = data[i]
|
|
333
|
+
maxn = i
|
|
334
|
+
# 계곡찾기 diff_pre > 0 and diff < 0: 봉우리찾기
|
|
335
|
+
if diff_pre < 0 and diff > 0:
|
|
336
|
+
break
|
|
337
|
+
diff_pre = diff
|
|
338
|
+
return maxn, time[maxn], data[maxn]
|
|
339
|
+
|
|
340
|
+
def GetPISteadyStateError(self, EntityName):
|
|
341
|
+
time = np.array(self.modelDocument.GetPlotDataTime())
|
|
342
|
+
data = np.array(self.GetPlotData(EntityName))
|
|
343
|
+
return len(time) - 1, time[-1], data[-1]
|
|
344
|
+
|
|
345
|
+
def GetPIPassingTime(self, time, data, target=0.0, count=1):
|
|
346
|
+
cnt = 0
|
|
347
|
+
rn = len(time)
|
|
348
|
+
pV = target - data[0]
|
|
349
|
+
for i in range(1, rn):
|
|
350
|
+
cV = target - data[i]
|
|
351
|
+
if pV * cV <= 0.0:
|
|
352
|
+
cnt += 1
|
|
353
|
+
if cnt == count:
|
|
354
|
+
return np.interp(target, [data[i - 1], data[i]], [time[i - 1], time[i]])
|
|
355
|
+
pV = cV
|
|
356
|
+
return 0
|
|
357
|
+
|
|
358
|
+
def SetAnalysisResponse(self, x):
|
|
359
|
+
self.modelDocument.SetAnalysisResponseResult(x)
|
|
360
|
+
|
|
361
|
+
def __del__(self):
|
|
362
|
+
print("Destructor called")
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
MSG_LEGEND_L23 = ['Case', 'RD_Ver', 'Flatform', 'GC', 'nBody', 'DOF', 'Threads', 'SimTime', 'Steps', 'Hmax',
|
|
366
|
+
'Error', 'Ndmp',
|
|
367
|
+
'CPUtime', 'hmax', 'hmin', 'normmax', 'normmin', 'NJAC', 'NRES', 'ANRF', 'AINTF', 'NFJAC',
|
|
368
|
+
'StepCPUTime']
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
MSG_LEGEND_L21 = ['Case', 'RD_Ver', 'Flatform', 'GC', 'nBody', 'DOF', 'Threads', 'SimTime', 'Steps', 'Hmax',
|
|
372
|
+
'Error', 'Ndmp', 'CPUtime', 'hmax', 'hmin', 'normmax', 'normmin',
|
|
373
|
+
'NJAC', 'NRES', 'ANRF', 'AINTF']
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
MSG_LEGEND_EXT = ['Case', 'RD_Ver', 'Flatform', 'GC', 'nBody', 'DOF', 'Threads', 'SimTime', 'Steps', 'Hmax',
|
|
377
|
+
'Error', 'Ndmp', 'CPUtime', 'hmax', 'hmin', 'normmax', 'normmin',
|
|
378
|
+
'NJAC', 'NRES', 'ANRF', 'AINTF', 'NFJAC', 'STEPMAX']
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
MSG_LEGEND_STATIC = ['Case', 'RD_Ver', 'Flatform', 'GC', 'BodyNum', 'DOF', 'Threads', 'SimTime', 'Steps', 'MaxIter',
|
|
382
|
+
'Error', 'CPUtime',
|
|
383
|
+
'ConvFactor', 'TMoveLimit', 'RMoveLimit', 'ScaledFlag', 'DampFlag',
|
|
384
|
+
'EndIter', 'MaxDNorm',
|
|
385
|
+
'nRes', 'nResFlex', 'nJac', 'nJacFlex']
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
class Post:
|
|
389
|
+
def __init__(self, rplt_path):
|
|
390
|
+
self.rplts = []
|
|
391
|
+
rplt_path = str_to_liststr(rplt_path)
|
|
392
|
+
for file in rplt_path:
|
|
393
|
+
if os.path.exists(file):
|
|
394
|
+
self.rplts.append(RpltReader(file))
|
|
395
|
+
print("Imported rplt:" + file)
|
|
396
|
+
# try:
|
|
397
|
+
# self.rplts.append(RpltReader(file))
|
|
398
|
+
#
|
|
399
|
+
# except:
|
|
400
|
+
# exit("Invalid path:" + file)
|
|
401
|
+
self.nrplt = len(self.rplts)
|
|
402
|
+
|
|
403
|
+
def DrawPlotY(self, y_data, ylabel=None, lgds=None, title=None, rplt_idx=[-1]):
|
|
404
|
+
# Deal single x, y data case
|
|
405
|
+
y_data = str_to_liststr(y_data)
|
|
406
|
+
lgds = str_to_liststr(lgds)
|
|
407
|
+
data = []
|
|
408
|
+
plt.figure(title)
|
|
409
|
+
# data draw
|
|
410
|
+
draw_y_name = []
|
|
411
|
+
for idx in rplt_idx:
|
|
412
|
+
x = self.rplts[idx].get_plot_data("TIME")
|
|
413
|
+
for i, y_name in enumerate(y_data):
|
|
414
|
+
try:
|
|
415
|
+
y = self.rplts[idx].get_plot_data(y_name)
|
|
416
|
+
plt.plot(x, y)
|
|
417
|
+
data.append(y)
|
|
418
|
+
draw_y_name.append(y_name)
|
|
419
|
+
except:
|
|
420
|
+
print("invalid data name: " + y_name)
|
|
421
|
+
plt.xlabel("Time(sec)")
|
|
422
|
+
if ylabel is not None:
|
|
423
|
+
plt.ylabel(ylabel)
|
|
424
|
+
if lgds is not None:
|
|
425
|
+
plt.legend(lgds, loc="upper right", fancybox="true", fontsize=11)
|
|
426
|
+
else:
|
|
427
|
+
plt.legend(draw_y_name, loc="upper right", fancybox="true", fontsize=11)
|
|
428
|
+
plt.tight_layout() # plt.figure(i).tight_layout(rect=[0, 0.03, 1, 0.95])
|
|
429
|
+
return data
|
|
430
|
+
|
|
431
|
+
def GetData(self, data_names, rplt_idx=-1):
|
|
432
|
+
if rplt_idx > self.nrplt - 1:
|
|
433
|
+
print("invalid rplt index: " + str(rplt_idx) + "/" + str(self.nrplt - 1))
|
|
434
|
+
return
|
|
435
|
+
data_names = str_to_liststr(data_names)
|
|
436
|
+
data = []
|
|
437
|
+
for name in data_names:
|
|
438
|
+
data.append(self.rplts[rplt_idx].get_plot_data(name))
|
|
439
|
+
if data[-1] is None:
|
|
440
|
+
print(name)
|
|
441
|
+
exit("Invalid data name! during extract rplt data")
|
|
442
|
+
if len(data) == 1:
|
|
443
|
+
return data[0]
|
|
444
|
+
else:
|
|
445
|
+
return data
|
|
446
|
+
|
|
447
|
+
def GetName(self, strs, rplt_idx=0):
|
|
448
|
+
if rplt_idx > self.nrplt - 1:
|
|
449
|
+
print("invalid rplt index: " + str(rplt_idx) + "/" + str(self.nrplt - 1))
|
|
450
|
+
return
|
|
451
|
+
data_names = []
|
|
452
|
+
for name in self.rplts[rplt_idx].get_plottable_name_list():
|
|
453
|
+
include_all = True
|
|
454
|
+
for text in str_to_liststr(strs):
|
|
455
|
+
if str(text).upper() not in name.upper():
|
|
456
|
+
include_all = False
|
|
457
|
+
break
|
|
458
|
+
if include_all:
|
|
459
|
+
data_names.append(name)
|
|
460
|
+
return data_names
|
|
461
|
+
|
|
462
|
+
def GetNameCSV(self, csv_strs, rplt_idx=0):
|
|
463
|
+
if rplt_idx > self.nrplt - 1:
|
|
464
|
+
print("invalid rplt index: " + str(rplt_idx) + "/" + str(self.nrplt - 1))
|
|
465
|
+
return
|
|
466
|
+
data_names = []
|
|
467
|
+
strs = csv_strs.split(",")
|
|
468
|
+
for name in self.rplts[rplt_idx].get_plottable_name_list():
|
|
469
|
+
include_all = True
|
|
470
|
+
for text in str_to_liststr(strs):
|
|
471
|
+
if str(text).upper().strip() not in name.upper():
|
|
472
|
+
include_all = False
|
|
473
|
+
break
|
|
474
|
+
if include_all:
|
|
475
|
+
data_names.append(name)
|
|
476
|
+
return data_names
|
|
477
|
+
|
|
478
|
+
def Show(self):
|
|
479
|
+
plt.show()
|