Skip to content

Commit

Permalink
Merge branch 'master' into codespell_faster_workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fmckenna authored Sep 19, 2024
2 parents 87bdfda + 5c08650 commit 72c4bc3
Show file tree
Hide file tree
Showing 170 changed files with 11,115 additions and 1,466 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ UserDefinedEDP
SiteResponse
MDOF_BuildingModel
ExtractPGA
StochasticWind
StochasticGroundMotion
StandardEarthquakeEDP
OpenSeesInput
OpenSeesPostprocessor
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PROJECT(SimCenterBackendApplications)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "" FORCE)

SET (CONAN_DISABLE_CHECK_COMPILER ON)
include(SimCenterFunctions)
include(CMakeParseArguments)

Expand Down
25 changes: 15 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 1.0.{build}
version: 24.07.{build}

image:
- Visual Studio 2019
- macOS
- Ubuntu1804
- Visual Studio 2019

stack: python 3.7
stack: python 3.9

for:
# macOS
Expand All @@ -18,13 +18,14 @@ for:

init:
- export PATH="$HOME/Qt/5.15.2/clang_64/bin:$HOME/venv3.9/bin:$PATH"
- python -m pip install --upgrade pip
- pip install conan
- python3 -m pip install --upgrade pip
- pip install conan==1.60.1
- conan user
- conan remote add simcenter https://nherisimcenter.jfrog.io/artifactory/api/conan/simcenter

install:
- uname
- rm -rf SimCenterBackendApplications
- git clone https://github.com/NHERI-SimCenter/SimCenterBackendApplications.git

build_script:
Expand All @@ -39,6 +40,7 @@ for:
- qmake --version
- gcc --version
- python --version
- python3 --version

# Ubuntu1804
-
Expand All @@ -49,17 +51,18 @@ for:
clone_folder: ~/SimCenter

init:
- export PATH="$HOME/Qt/5.15.2/gcc_64/bin:$HOME/venv3.8.6/bin:$PATH"
- export PATH="$HOME/Qt/5.15.2/gcc_64/bin:$HOME/venv3.9/bin:$PATH"
- export PATH="/home/appveyor/.local/bin:$PATH"

install:
- uname
- sudo update-alternatives --set gcc /usr/bin/gcc-9
- sudo apt-get -y install libglu1-mesa-dev freeglut3-dev mesa-common-dev libblas-dev liblapack-dev
- python -m pip install --upgrade pip
- pip install conan
- python3 -m pip install --upgrade pip
- pip install conan==1.60.1
- conan user
- conan remote add simcenter https://nherisimcenter.jfrog.io/artifactory/api/conan/simcenter
- rm -rf SimCenterBackendApplications
- git clone https://github.com/NHERI-SimCenter/SimCenterBackendApplications.git

build_script:
Expand All @@ -73,6 +76,7 @@ for:
- qmake --version
- gcc --version
- python --version
- python3 --version

# Visual Studio 2019
-
Expand All @@ -85,11 +89,11 @@ for:

init:
- cmd: set PYTHON=C:\PYTHON38-x64
- cmd: set PYTHONNET_PYDLL=%PYTHON%\python3.8.dll
- cmd: set PYTHONNET_PYDLL=%PYTHON%\python3.9.dll
- cmd: set QT=C:\Qt\5.15.2\msvc2019_64\bin
- cmd: set PATH=%PYTHON%;%PYTHON%\Scripts;%QT%;%PATH%
- cmd: call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- cmd: pip.exe install conan
- cmd: pip.exe install conan==1.60.1
- cmd: conan user
- cmd: conan profile new default --detect
- cmd: conan profile show default
Expand All @@ -99,6 +103,7 @@ for:
- cmd: echo %PATH%

install:
- cmd: rm -rf SimCenterBackendApplications
- cmd: git clone https://github.com/NHERI-SimCenter/SimCenterBackendApplications.git
- cmd: dir

Expand Down
4 changes: 2 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class simCenterBackendApps(ConanFile): # noqa: D101
}
options = {'shared': [True, False]} # noqa: RUF012
default_options = { # noqa: RUF012
'mkl-static:threaded': False,
'ipp-static:simcenter_backend': True,
'libcurl:with_ssl': 'openssl',
}
generators = 'cmake'
Expand All @@ -33,6 +31,8 @@ class simCenterBackendApps(ConanFile): # noqa: D101
'jsonformoderncpp/3.7.0',
'nanoflann/1.3.2',
'nlopt/2.7.1',
'boost/1.71.0',
'kissfft/131.1.0',
]

# Custom attributes for Bincrafters recipe conventions
Expand Down
3 changes: 2 additions & 1 deletion modules/Workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ simcenter_add_python_script(SCRIPT changeJSON.py)
simcenter_add_python_script(SCRIPT "sWHALE.py")
simcenter_add_python_script(SCRIPT "qWHALE.py")
simcenter_add_python_script(SCRIPT "rWHALE.py")
simcenter_add_python_script(SCRIPT "createResponseCSV.py")
simcenter_add_python_script(SCRIPT "siteResponseWHALE.py")
simcenter_add_python_script(SCRIPT "createGM4BIM.py")
simcenter_add_python_script(SCRIPT "computeResponseSpectrum.py")
Expand All @@ -19,4 +20,4 @@ simcenter_add_python_script(SCRIPT R2DTool_workflow.py)
simcenter_add_python_script(SCRIPT CreateWorkflowJobs.py)

simcenter_add_executable(NAME runMultiModelDriver
FILES runMultiModelDriver.cpp)
FILES runMultiModelDriver.cpp)
4 changes: 4 additions & 0 deletions modules/Workflow/WorkflowApplications.json
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,10 @@
"Name": "IMasEDP",
"ExecutablePath": "applications/performSIMULATION/IMasEDP/IMasEDP.py"
},
{
"Name": "CapacitySpectrumMethod",
"ExecutablePath": "applications/performSIMULATION/capacitySpectrum/runCMS.py"
},
{
"Name": "SurrogateSimulation",
"ExecutablePath": "applications/performSIMULATION/surrogateSimulation/SurrogateSimulation.py"
Expand Down
8 changes: 4 additions & 4 deletions modules/Workflow/computeResponseSpectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def convert_accel_units(acceleration, from_, to_='cm/s/s'): # noqa: C901
acceleration = np.asarray(acceleration)
if from_ == 'g':
if to_ == 'g':
return acceleration
return acceleration # noqa: DOC201, RUF100
if to_ in m_sec_square:
return acceleration * g
if to_ in cm_sec_square:
Expand Down Expand Up @@ -70,7 +70,7 @@ def get_velocity_displacement(
velocity = time_step * cumtrapz(acceleration, initial=0.0)
if displacement is None:
displacement = time_step * cumtrapz(velocity, initial=0.0)
return velocity, displacement
return velocity, displacement # noqa: DOC201, RUF100


class NewmarkBeta:
Expand Down Expand Up @@ -160,7 +160,7 @@ def run(self):
'PGV': np.max(np.fabs(self.velocity)),
'PGD': np.max(np.fabs(self.displacement)),
}
return self.response_spectrum, time_series, accel, vel, disp
return self.response_spectrum, time_series, accel, vel, disp # noqa: DOC201, RUF100

def _newmark_beta(self, omega, cval, kval): # noqa: ARG002
"""Newmark-beta integral
Expand Down Expand Up @@ -216,4 +216,4 @@ def _newmark_beta(self, omega, cval, kval): # noqa: ARG002
disp[j, :] = delta_u + disp[j - 1, :]
a_t[j, :] = ground_acc[j] + accel[j, :]

return accel, vel, disp, a_t
return accel, vel, disp, a_t # noqa: DOC201, RUF100
36 changes: 18 additions & 18 deletions modules/Workflow/createGM4BIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_scale_factors(input_units, output_units): # noqa: C901

scale_factors.update({input_name: f_scale})

return scale_factors
return scale_factors # noqa: DOC201, RUF100


def createFilesForEventGrid(inputDir, outputDir, removeInputDir): # noqa: C901, N802, N803, D103, PLR0915
Expand Down Expand Up @@ -410,28 +410,28 @@ def createFilesForEventGrid(inputDir, outputDir, removeInputDir): # noqa: C901,
m_pgd_y = 0.0
s_pgd_y = 0.0
# add to dictionary
dict_im[('type', 'loc', 'dir', 'stat')].append(int(siteID))
dict_im[('type', 'loc', 'dir', 'stat')].append(int(siteID)) # noqa: RUF031, RUF100
# pga
dict_im[('PGA', 0, 1, 'median')].append(m_pga_x)
dict_im[('PGA', 0, 1, 'beta')].append(s_pga_x)
dict_im[('PGA', 0, 2, 'median')].append(m_pga_y)
dict_im[('PGA', 0, 2, 'beta')].append(s_pga_y)
dict_im[('PGA', 0, 1, 'median')].append(m_pga_x) # noqa: RUF031, RUF100
dict_im[('PGA', 0, 1, 'beta')].append(s_pga_x) # noqa: RUF031, RUF100
dict_im[('PGA', 0, 2, 'median')].append(m_pga_y) # noqa: RUF031, RUF100
dict_im[('PGA', 0, 2, 'beta')].append(s_pga_y) # noqa: RUF031, RUF100
# pgv
dict_im[('PGV', 0, 1, 'median')].append(m_pgv_x)
dict_im[('PGV', 0, 1, 'beta')].append(s_pgv_x)
dict_im[('PGV', 0, 2, 'median')].append(m_pgv_y)
dict_im[('PGV', 0, 2, 'beta')].append(s_pgv_y)
dict_im[('PGV', 0, 1, 'median')].append(m_pgv_x) # noqa: RUF031, RUF100
dict_im[('PGV', 0, 1, 'beta')].append(s_pgv_x) # noqa: RUF031, RUF100
dict_im[('PGV', 0, 2, 'median')].append(m_pgv_y) # noqa: RUF031, RUF100
dict_im[('PGV', 0, 2, 'beta')].append(s_pgv_y) # noqa: RUF031, RUF100
# pgd
dict_im[('PGD', 0, 1, 'median')].append(m_pgd_x)
dict_im[('PGD', 0, 1, 'beta')].append(s_pgd_x)
dict_im[('PGD', 0, 2, 'median')].append(m_pgd_y)
dict_im[('PGD', 0, 2, 'beta')].append(s_pgd_y)
dict_im[('PGD', 0, 1, 'median')].append(m_pgd_x) # noqa: RUF031, RUF100
dict_im[('PGD', 0, 1, 'beta')].append(s_pgd_x) # noqa: RUF031, RUF100
dict_im[('PGD', 0, 2, 'median')].append(m_pgd_y) # noqa: RUF031, RUF100
dict_im[('PGD', 0, 2, 'beta')].append(s_pgd_y) # noqa: RUF031, RUF100
for jj, Ti in enumerate(periods): # noqa: N806
cur_sa = f'SA({Ti}s)'
dict_im[(cur_sa, 0, 1, 'median')].append(m_psa_x[jj])
dict_im[(cur_sa, 0, 1, 'beta')].append(s_psa_x[jj])
dict_im[(cur_sa, 0, 2, 'median')].append(m_psa_y[jj])
dict_im[(cur_sa, 0, 2, 'beta')].append(s_psa_y[jj])
dict_im[(cur_sa, 0, 1, 'median')].append(m_psa_x[jj]) # noqa: RUF031, RUF100
dict_im[(cur_sa, 0, 1, 'beta')].append(s_psa_x[jj]) # noqa: RUF031, RUF100
dict_im[(cur_sa, 0, 2, 'median')].append(m_psa_y[jj]) # noqa: RUF031, RUF100
dict_im[(cur_sa, 0, 2, 'beta')].append(s_psa_y[jj]) # noqa: RUF031, RUF100

# aggregate
for cur_key, cur_value in dict_im.items():
Expand Down
89 changes: 89 additions & 0 deletions modules/Workflow/createResponseCSV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# noqa: D100, INP001

#
# Code to write response.csv file given input and dakotaTab.out files
#

# Written fmk, important code copied from whale/main.py
# date: 08/24

import argparse
import json
import os

import numpy as np
import pandas as pd


def main(input_file, dakota_tab_file): # noqa: D103
directory_inputs = os.path.dirname(input_file) # noqa: PTH120
os.chdir(directory_inputs)

try:
# Attempt to open the file
with open(input_file) as file: # noqa: PTH123
data = json.load(file)

except FileNotFoundError:
# Handle the error if the file is not found
print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201
return
except OSError:
# Handle other I/O errors
print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201
return

app_data = data.get('Applications', None)
if app_data is not None:
dl_data = app_data.get('DL', None)

if dl_data is not None:
dl_app_data = dl_data.get('ApplicationData', None)

if dl_app_data is not None:
is_coupled = dl_app_data.get('coupled_EDP', None)

try:
# sy, abs - added try-statement because dakota-reliability does not write DakotaTab.out
dakota_out = pd.read_csv(dakota_tab_file, sep=r'\s+', header=0, index_col=0)

if is_coupled:
if 'eventID' in dakota_out.columns:
events = dakota_out['eventID'].values # noqa: PD011
events = [int(e.split('x')[-1]) for e in events]
sorter = np.argsort(events)
dakota_out = dakota_out.iloc[sorter, :]
dakota_out.index = np.arange(dakota_out.shape[0])

dakota_out.to_csv('response.csv')

except FileNotFoundError:
# Handle the error if the file is not found
print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201
return

except OSError:
# Handle other I/O errors
print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201
return


if __name__ == '__main__':
parser = argparse.ArgumentParser()

# Add arguments with default values
parser.add_argument(
'--inputFile', type=str, default='AIM.json', help='Path to the input file)'
)
parser.add_argument(
'--dakotaTab',
type=str,
default='dakotaTab.out',
help='Path to the dakotaTab file)',
)

# Parse the arguments
args = parser.parse_args()

# Use the arguments
main(args.inputFile, args.dakotaTab)
Loading

0 comments on commit 72c4bc3

Please sign in to comment.