4242import matplotlib as mpl
4343import matplotlib .pyplot as plt
4444import numpy as np
45- import pandas as pd
4645
4746# Check if taichi is installed before importing taichi
4847try :
@@ -96,7 +95,7 @@ def __init__(self, recorderID=-1): # noqa: N803
9695 continue
9796 # Assume there is no header in the file
9897 # Assume recorder IDs are sequential, starting from 1
99- if (j + 1 ) == recorderID :
98+ if (j ) == recorderID :
10099 # Strip away leading / trailing white-space,
101100 # Delimit by regex to capture " ", \s, " ", tabs, etc.
102101 # Each value should be a number, rep. the force on recorder j at a time-step i
@@ -173,16 +172,14 @@ def addFloorForceToEvent( # noqa: N802
173172 Add force (one component) time series and pattern in the event file
174173 Use of Wind is just a placeholder for now, since its more developed than Hydro
175174 """ # noqa: D205, D400
176- seriesName = '1' # noqa: N806
177- patternName = '1' # noqa: N806
178175 seriesName = 'WindForceSeries_' + str (floor ) + direction # noqa: N806
179176 patternName = 'WindForcePattern_' + str (floor ) + direction # noqa: N806
180177
181178 pattern = {
182179 'name' : patternName ,
183180 'timeSeries' : seriesName ,
184181 'numSteps' : len (force .X ),
185- 'dT' : 0.01 ,
182+ 'dT' : dt ,
186183 'type' : 'WindFloorLoad' ,
187184 'floor' : str (floor ),
188185 'story' : str (floor ),
@@ -196,8 +193,8 @@ def addFloorForceToEvent( # noqa: N802
196193 'dof' : directionToDof (direction ),
197194 'floor' : str (floor ),
198195 'story' : str (floor ),
199- 'dT' : 0.01 ,
200- 'dt' : 0.01 ,
196+ 'dT' : dt ,
197+ 'dt' : dt ,
201198 'numSteps' : len (force .X ),
202199 'data' : force .X ,
203200 }
@@ -242,8 +239,8 @@ def writeEVENT(forces, eventFilePath='EVENT.json', floorsCount=1): # noqa: N802
242239 'timeSeries' : timeSeriesArray ,
243240 'pressure' : pressure ,
244241 'numSteps' : len (forces [0 ].X ),
245- 'dT' : 1.0 ,
246- 'dt' : 1.0 ,
242+ 'dT' : dt ,
243+ 'dt' : dt ,
247244 'units' : {'force' : 'Newton' , 'length' : 'Meter' , 'time' : 'Sec' },
248245 }
249246
@@ -265,23 +262,24 @@ def GetFloorsCount(BIMFilePath): # noqa: N802, N803, D103
265262 return int (bim ['GeneralInformation' ]['stories' ])
266263
267264
268- def GetCelerisScript (BIMFilePath ): # noqa: N802, N803, D103
269- filePath = BIMFilePath # noqa: N806
270- with open (filePath , encoding = 'utf-8' ) as file : # noqa: PTH123
271- evt = json .load (file )
272- file .close # noqa: B018
265+ def GetCelerisScript (): # noqa: N802, N803, D103
266+ # filePath = BIMFilePath # noqa: N806
267+ # with open(filePath, encoding='utf-8') as file: # noqa: PTH123
268+ # evt = json.load(file)
269+ # file.close # noqa: B018
273270
274- fileNameKey = 'simulationScript' # noqa: N806
275- filePathKey = fileNameKey + 'Path' # noqa: N806
271+ # fileNameKey = 'simulationScript' # noqa: N806
272+ # filePathKey = fileNameKey + 'Path' # noqa: N806
276273
277- for event in evt ['Events' ]:
278- fileName = event [fileNameKey ] # noqa: N806
279- filePath = event [filePathKey ] # noqa: N806
280- return os .path .join (filePath , fileName ) # noqa: PTH118
274+ # for event in evt['Events']:
275+ # fileName = event[fileNameKey] # noqa: N806
276+ # filePath = event[filePathKey] # noqa: N806
277+ # return os.path.join(filePath, fileName) # noqa: PTH118
281278
282279 defaultScriptPath = f'{ os .path .realpath (os .path .dirname (__file__ ))} ' # noqa: N806, PTH120
283280 defaultScriptName = 'setrun.py' # noqa: N806
284- return defaultScriptPath + defaultScriptName
281+ defaultScriptPath = os .path .join (defaultScriptPath , defaultScriptName ) # noqa: PTH118
282+ return defaultScriptPath # noqa: PTH118
285283
286284
287285def main ():
@@ -314,25 +312,21 @@ def main():
314312 default = 'EVENT.json' ,
315313 )
316314 parser .add_argument ('--getRV' , help = 'getRV' , required = False , action = 'store_true' )
317- # parser.add_argument('--filenameSAM', default=None)
318-
315+
319316 # parsing arguments
320317 arguments , unknowns = parser .parse_known_args ()
321318
322- # import subprocess
323-
324319 # Get json of filenameAIM
325- scriptName = GetCelerisScript (arguments .filenameAIM ) # noqa: N816
326-
327320 filePath = arguments .filenameAIM # noqa: N816
328321 with open (filePath , encoding = 'utf-8' ) as file : # noqa: PTH123
329322 evt = json .load (file )
330323 file .close # noqa: B018
331324
325+ scriptName = GetCelerisScript () # noqa: N816
326+ caseDirectory = './examples/CrescentCity' # noqa: N816
332327 configFilename = 'config.json' # noqa: N816
333328 bathymetryFilename = 'bathymetry.txt' # noqa: N816
334329 waveFilename = 'wave.txt' # noqa: N816
335- caseDirectory = './examples/CrescentCity' # noqa: N816
336330
337331 for event in evt ['Events' ]:
338332 # Redesign the input structure in backend CelerisAi later.
@@ -341,38 +335,25 @@ def main():
341335 configFilename = event ['configFile' ] # noqa: N816
342336 bathymetryFilename = event ['bathymetryFile' ] # noqa: N816
343337 waveFilename = event ['waveFile' ] # noqa: N816
338+ # Check for event['config']['dt'] in the event file
339+ # and set dt to the value in the event file
340+ # if not found, set dt to 0.01
341+ dt = event ['config' ]['dt' ] if 'dt' in event ['config' ] else 0.01
344342
345343 print ('Running Celeris with script:' , scriptName ) # noqa: T201
346344 print ('Running Celeris with directory:' , caseDirectory ) # noqa: T201
347345 print ('Running Celeris with config file:' , configFilename ) # noqa: T201
348346 print ('Running Celeris with bathymetry:' , bathymetryFilename ) # noqa: T201
349347 print ('Running Celeris with waves:' , waveFilename ) # noqa: T201
350348
349+ floorsCount = 1 # noqa: N816
350+
351351 if arguments .getRV == True : # noqa: E712
352352 print ('RVs requested' ) # noqa: T201
353353 # Read the number of floors
354354 floorsCount = GetFloorsCount (arguments .filenameAIM ) # noqa: N816
355355 filenameEVENT = arguments .filenameEVENT # noqa: N816
356-
357- # result = subprocess.run( # noqa: S603
358- # [ # noqa: S607
359- # sys.executable,
360- # scriptName,
361- # '-d',
362- # caseDirectory,
363- # '-f',
364- # configFilename,
365- # '-b',
366- # bathymetryFilename,
367- # '-w',
368- # waveFilename,
369- # # f'{os.path.realpath(os.path.dirname(__file__))}'
370- # # + '/taichi_script.py',
371- # ],
372- # stdout=subprocess.PIPE,
373- # check=False,
374- # )
375-
356+
376357 forces = []
377358 for i in range (floorsCount ):
378359 forces .append (FloorForces (recorderID = (i + 1 ))) # noqa: PERF401
@@ -405,15 +386,12 @@ def main():
405386 bathymetryFilename ,
406387 '-w' ,
407388 waveFilename ,
408- # f'{os.path.realpath(os.path.dirname(__file__))}'
409- # + '/taichi_script.py',
410389 ],
411390 stdout = subprocess .PIPE ,
412391 check = False ,
413392 )
414393
415394 forces = []
416- floorsCount = 1 # noqa: N816
417395 for i in range (floorsCount ):
418396 forces .append (FloorForces (recorderID = (i + 1 )))
419397
0 commit comments