-
Notifications
You must be signed in to change notification settings - Fork 0
/
doe_gui.py
72 lines (68 loc) · 3.05 KB
/
doe_gui.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
from recurdyn import *
from GlobalVariables import GlobVar
from . import initialize, dispose
from utils.modeling import *
from utils.sampling import *
import time
import os
def RunDOE_GUI(
ModelFileDir: str = f"{os.getcwd()}/SampleModel.rdyn",
TopFolderName: str = "TestDOE_GUI",
NumCPUCores: int = 8,
EndTime: float = 1,
NumSteps: int = 100,
) -> None:
"""
Run automated simulations in GUI interface solver.
:param TopFolderName: A new directory for solved files.
:param NumCPUCores: Number of CPU threads for solving. 'AUTO' if 0. [1,2,4,8,16] are supported values.
:return:
"""
application, model_document, plot_document, model = initialize()
application.ClearMessage()
assert type(NumSteps) == int, "NumSteps must be integer."
assert NumCPUCores in [
0,
1,
2,
4,
8,
16,
], "NumCPUCores must be one of 0,1,2,4,8,16."
model_document = application.OpenModelDocument(ModelFileDir)
modelPath = model_document.GetPath(PathType.WorkingFolder)
model = model_document.Model
application.Settings.CreateOutputFolder = False
model_document.UseOutputFileName = True
model_document.ModelProperty.DynamicAnalysisProperty.SimulationStep.Value = NumSteps
model_document.ModelProperty.DynamicAnalysisProperty.SimulationTime.Value = EndTime
model_document.ModelProperty.DynamicAnalysisProperty.MatchSolvingStepSize = True
model_document.ModelProperty.DynamicAnalysisProperty.MatchSimulationEndTime = True
if NumCPUCores:
application.Settings.AutoCoreNumber = False
application.Settings.CoreNumber = NumCPUCores
else:
application.Settings.AutoCoreNumber = True
application.ClearMessage()
AnalysisStartTime = time.perf_counter()
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
Counter = 1
SamplePV = np.logspace(-2, 10, 10, endpoint=True)
for samplepv in SamplePV:
ChangePVvalue(model, "PV_SampleK", samplepv)
SubFolderName = f"{TopFolderName}_{Counter:04d}"
model_document.OutputFileName = (
f"{TopFolderName}\\{SubFolderName}\\{SubFolderName}"
)
model_document.Analysis(AnalysisMode.Dynamic)
Counter += 1
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
######################################### EDIT HERE #########################################
AnalysisEndTime = time.perf_counter()
s = AnalysisEndTime - AnalysisStartTime
print(f"Analysis finished within {s:.2f}sec.")