-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
109 lines (91 loc) · 3.54 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from recurdyn import *
# from recurdyn import Chart
# from recurdyn import MTT2D
# from recurdyn import FFlex
# from recurdyn import RFlex
from recurdyn import Tire
from datetime import datetime
import numpy as np
import re, os, glob, os
import pandas as pd
from utils.modeling import *
from analysis.doe_batch import *
from analysis.doe_gui import *
from analysis.export_data import *
app = None
application = None
model_document = None
plot_document = None
model = None
ref_frame_1 = None
ref_frame_2 = None
# initialize() should be called before ProcessNet function call.
def initialize():
global app
global application
global model_document
global plot_document
global model
app = dispatch_recurdyn()
application = IApplication(app.RecurDynApplication)
model_document = application.ActiveModelDocument
if model_document is not None:
model_document = IModelDocument(model_document)
plot_document = application.ActivePlotDocument
if plot_document is not None:
plot_document = IPlotDocument(plot_document)
if model_document is None and plot_document is None:
application.PrintMessage("No model file")
model_document = application.NewModelDocument("Examples")
if model_document is not None:
model_document = IModelDocument(model_document)
model = ISubSystem(model_document.Model)
return application, model_document, plot_document, model
# dispose() should be called after ProcessNet function call.
def dispose():
global application
global model_document
model_document = application.ActiveModelDocument
if model_document is not None:
model_document = IModelDocument(model_document)
else:
return
if not model_document.Validate():
return
# Redraw() and UpdateDatabaseWindow() can take more time in a heavy model.
# model_document.Redraw()
# model_document.PostProcess() # UpdateDatabaseWindow(), SetModified()
# model_document.UpdateDatabaseWindow()
# If you call SetModified(), Animation will be reset.
# model_document.SetModified()
model_document.SetUndoHistory("Python ProcessNet")
if __name__ == "__main__":
application, model_document, plot_document, model = initialize()
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
# GUI solver (not parallelized)
RunDOE_GUI(
ModelFileDir=f"{os.getcwd()}/SampleModel.rdyn",
TopFolderName="TestDOE_GUI",
NumCPUCores=8,
EndTime=1,
NumSteps=100,
)
rplt2csv(f"{os.getcwd()}/TestDOE_GUI")
# Batch solver (parallelized)
RunDOE_Batch(
ModelFileDir=f"{os.getcwd()}/SampleModel.rdyn",
TopFolderName="TestDOE_Batch",
NumCPUCores=8,
EndTime=1,
NumSteps=100,
NumParallelBatches=5,
)
rplt2csv(f"{os.getcwd()}/TestDOE_Batch")
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
dispose()