Skip to content

Commit

Permalink
Merge pull request #318 from jinyan1214/master
Browse files Browse the repository at this point in the history
JZ - Capacity Spectrum method in R2D and parallel site creation of EQ Tool in R2D
  • Loading branch information
fmckenna authored Sep 16, 2024
2 parents 0a79a55 + 03cf289 commit 05759d6
Show file tree
Hide file tree
Showing 39 changed files with 2,544 additions and 522 deletions.
5 changes: 3 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from conans import CMake, ConanFile


class simCenterBackendApps(ConanFile): # noqa: D101
name = 'SimCenterBackendApplications'
version = '1.2.2'
Expand Down Expand Up @@ -30,8 +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'
'boost/1.71.0',
'kissfft/131.1.0',
]

# Custom attributes for Bincrafters recipe conventions
Expand Down
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
9 changes: 5 additions & 4 deletions modules/createAIM/GeoJSON_to_ASSET/GeoJSON_to_ASSET.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import argparse # noqa: INP001, D100
import argparse # noqa: D100, INP001
import importlib
import json
import os
Expand All @@ -8,7 +8,8 @@
import warnings

import geopandas as gpd
import momepy

# import momepy
import numpy as np
import pandas as pd
import shapely
Expand Down Expand Up @@ -179,10 +180,10 @@ def defineConnectivities( # noqa: N802, D102
# Convert find connectivity and add start_node, end_node attributes
edges = self.gdf
datacrs = edges.crs
graph = momepy.gdf_to_nx(edges.to_crs('epsg:6500'), approach='primal')
graph = momepy.gdf_to_nx(edges.to_crs('epsg:6500'), approach='primal') # noqa: F821
with warnings.catch_warnings(): # Suppress the warning of disconnected components in the graph
warnings.simplefilter('ignore')
nodes, edges, sw = momepy.nx_to_gdf(
nodes, edges, sw = momepy.nx_to_gdf( # noqa: F821
graph, points=True, lines=True, spatial_weights=True
)
# edges = edges.set_index('ind')
Expand Down
9 changes: 5 additions & 4 deletions modules/createAIM/INP_FILE/INP_FILE.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import argparse # noqa: INP001, D100
import argparse # noqa: D100, INP001
import importlib
import json
import os
Expand All @@ -8,7 +8,8 @@
import warnings

import geopandas as gpd
import momepy

# import momepy
import numpy as np
import pandas as pd
import shapely
Expand Down Expand Up @@ -179,10 +180,10 @@ def defineConnectivities( # noqa: N802, D102
# Convert find connectivity and add start_node, end_node attributes
edges = self.gdf
datacrs = edges.crs
graph = momepy.gdf_to_nx(edges.to_crs('epsg:6500'), approach='primal')
graph = momepy.gdf_to_nx(edges.to_crs('epsg:6500'), approach='primal') # noqa: F821
with warnings.catch_warnings(): # Suppress the warning of disconnected components in the graph
warnings.simplefilter('ignore')
nodes, edges, sw = momepy.nx_to_gdf(
nodes, edges, sw = momepy.nx_to_gdf( # noqa: F821
graph, points=True, lines=True, spatial_weights=True
)
# edges = edges.set_index('ind')
Expand Down
7 changes: 4 additions & 3 deletions modules/createAIM/JSON_to_AIM/JSON_to_AIM_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
import warnings

import geopandas as gpd
import momepy

# import momepy
import numpy as np
import pandas as pd
import shapely
Expand Down Expand Up @@ -358,10 +359,10 @@ def create_asset_files( # noqa: C901, D103, PLR0915
roadDF['geometry'] = LineStringList
roadDF = roadDF[['ID', 'roadType', 'lanes', 'maxMPH', 'geometry']] # noqa: N806
roadGDF = gpd.GeoDataFrame(roadDF, geometry='geometry', crs=datacrs) # noqa: N806
graph = momepy.gdf_to_nx(roadGDF.to_crs('epsg:6500'), approach='primal')
graph = momepy.gdf_to_nx(roadGDF.to_crs('epsg:6500'), approach='primal') # noqa: F821
with warnings.catch_warnings(): # Suppress the warning of disconnected components in the graph
warnings.simplefilter('ignore')
nodes, edges, sw = momepy.nx_to_gdf(
nodes, edges, sw = momepy.nx_to_gdf( # noqa: F821
graph, points=True, lines=True, spatial_weights=True
)
# Oneway or twoway is not considered in D&L, remove duplicated edges
Expand Down
8 changes: 4 additions & 4 deletions modules/createEVENT/common/smelt/dabaghi_der_kiureghian.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ utilities::JsonObject stochastic::DabaghiDerKiureghian::generate(
}
}

// Baseline correct trunacted non-pulse-like motions
// Baseline correct truncated non-pulse-like motions
for (unsigned int i = 0; i < num_sims_nopulse_; ++i) {
for (unsigned int j = 0; j < num_realizations_; ++j) {
baseline_correct_time_history(nopulse_motions_comp1[i][j], gfactor,
Expand Down Expand Up @@ -787,7 +787,7 @@ void stochastic::DabaghiDerKiureghian::transform_parameters_from_normal_space(
params_fitted1_(17), params_fitted2_(17),
params_fitted3_(17), params_lower_bound_(17));

// Calculate depth_to_rupture compenent 2
// Calculate depth_to_rupture component 2
beta_dist =
Factory<stochastic::Distribution, double, double>::instance()->create(
"BetaDist", std::move(params_fitted1_(18)),
Expand Down Expand Up @@ -1203,7 +1203,7 @@ double stochastic::DabaghiDerKiureghian::calc_time_to_intensity(
std::vector<double> stochastic::DabaghiDerKiureghian::calc_linear_filter(
unsigned int num_steps, const Eigen::VectorXd& filter_params, double t01,
double tmid, double t99) const {
// Mininum frequency in Hz
// Minimum frequency in Hz
double min_freq = 0.3;
std::vector<double> filter_func(num_steps);
// Frequency at tmid, in Hz
Expand Down Expand Up @@ -1458,7 +1458,7 @@ void stochastic::DabaghiDerKiureghian::baseline_correct_time_history(
std::vector<double>& time_history, double gfactor,
unsigned int order) const {

// Calculate velocity and displacment time histories
// Calculate velocity and displacement time histories
std::vector<double> vel_series(time_history.size());
std::vector<double> disp_series(time_history.size());

Expand Down
8 changes: 4 additions & 4 deletions modules/createEVENT/common/smelt/dabaghi_der_kiureghian.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class DabaghiDerKiureghian : public StochasticModel {
unsigned int num_gms = 1) const;

/**
* Backcalculate modulating parameters given Arias Intesity and duration parameters
* Backcalculate modulating parameters given Arias Intensity and duration parameters
* @param[in] q_params Vector containing Ia, D595, D05, and D030
* @param[in] t0 Initial time. Defaults to 0.0.
* @return Vector containing parameters alpha, beta, tmaxq, and c
Expand Down Expand Up @@ -256,7 +256,7 @@ class DabaghiDerKiureghian : public StochasticModel {
* @param[in] d095_target Time from t0 to time of 95% Arias intensity of
* target motion
* @param[in] t0 Start time of modulating function and of target ground motion
* @return ERrro in modulating function
* @return error in modulating function
*/
double calc_parameter_error(const std::vector<double>& parameters,
double d05_target, double d030_target,
Expand Down Expand Up @@ -399,8 +399,8 @@ class DabaghiDerKiureghian : public StochasticModel {
Eigen::VectorXd std_dev_nopulse_; /**< No-pulse-like parameter standard deviation */
Eigen::MatrixXd corr_matrix_pulse_; /**< Pulse-like parameter correlation matrix */
Eigen::MatrixXd corr_matrix_nopulse_; /**< No-pulse-like parameter correlation matrix */
Eigen::MatrixXd beta_distribution_pulse_; /**< Beta distrubution parameters for pulse-like motion */
Eigen::MatrixXd beta_distribution_nopulse_; /**< Beta distrubution parameters for no-pulse-like motion */
Eigen::MatrixXd beta_distribution_pulse_; /**< Beta distribution parameters for pulse-like motion */
Eigen::MatrixXd beta_distribution_nopulse_; /**< Beta distribution parameters for no-pulse-like motion */
Eigen::VectorXd params_lower_bound_; /**< Lower bound for marginal distributions fitted to params
(Table 5 in Dabaghi & Der Kiureghian, 2017) */
Eigen::VectorXd params_upper_bound_; /**< Upper bound for marginal distributions fitted to params
Expand Down
2 changes: 1 addition & 1 deletion modules/createEVENT/common/smelt/json_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class JsonObject {

/**
* Get underlying JSON library object
* @return Copy of interal JSON implementation
* @return Copy of internal JSON implementation
*/
json get_library_json() const {
return json_object_;
Expand Down
4 changes: 2 additions & 2 deletions modules/createEVENT/common/smelt/nelder_mead.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ std::vector<double> optimization::NelderMead::minimize(
std::function<double(const std::vector<double>&)>& objective_function) {
// Create vector of deltas with length equal to the number of dimensions
std::vector<double> deltas(initial_point.size(), delta);
// Call minmize with vector of deltas
// Call minimize with vector of deltas
return minimize(initial_point, deltas, objective_function);
}

Expand All @@ -33,7 +33,7 @@ std::vector<double> optimization::NelderMead::minimize(
}
}

// Call minimize with matrix definining initial simplex
// Call minimize with matrix defining initial simplex
return minimize(simplex, objective_function);
}

Expand Down
4 changes: 2 additions & 2 deletions modules/createEVENT/common/smelt/numeric_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool convolve_1d(const std::vector<double>& input_x,
// conv_status = vsldConvExec1D(conv_task, input_x.data(), 1, input_y.data(), 1,
// response.data(), 1);

// // Check if convolution exectution was successful
// // Check if convolution execution was successful
// if (conv_status != VSL_STATUS_OK) {
// throw std::runtime_error(
// "\nERROR: in numeric_utils::convolve_1d: Error in convolution "
Expand Down Expand Up @@ -159,7 +159,7 @@ bool inverse_fft(std::vector<std::complex<double>> input_vector,
// }

// // Set the backward scale factor to be 1 divided by the size of the input vector
// // to make the backward tranform the inverse of the forward transform
// // to make the backward transform the inverse of the forward transform
// fft_status = DftiSetValue(fft_descriptor, DFTI_BACKWARD_SCALE,
// static_cast<double>(1.0 / input_vector.size()));
// if (fft_status != DFTI_NO_ERROR) {
Expand Down
2 changes: 1 addition & 1 deletion modules/createEVENT/common/smelt/vlachos_et_al.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ Eigen::VectorXd stochastic::VlachosEtAl::identify_parameters(
energy[i] = energy[i - 1] + 0.05;
}

// Initialze mode 1 parameters and frequencies
// Initialize mode 1 parameters and frequencies
std::vector<double> mode_1_params = {initial_params(2),
initial_params(3),
initial_params(4)};
Expand Down
4 changes: 2 additions & 2 deletions modules/createEVENT/common/smelt/vlachos_et_al.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class VlachosEtAl : public StochasticModel {
* @param[in, out] time_histories Location where time histories should be
* stored
* @param[in] parameters Set of model parameters to use for calculating power
* specturm and time histories
* spectrum and time histories
* @return Returns true if successful, false otherwise
*/
bool time_history_family(std::vector<std::vector<double>>& time_histories,
Expand Down Expand Up @@ -263,7 +263,7 @@ class VlachosEtAl : public StochasticModel {
Eigen::VectorXd means_; /**< Mean values of model parameters */
Eigen::MatrixXd covariance_; /**< Covariance matrix for model parameters */
std::vector<std::shared_ptr<stochastic::Distribution>>
model_parameters_; /**< Distrubutions for 18-parameter model */
model_parameters_; /**< Distributions for 18-parameter model */
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
parameter_realizations_; /**< Random realizations of normal model parameters */
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
Expand Down
48 changes: 24 additions & 24 deletions modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,30 +174,30 @@ int main(int argc, char **argv)
const char *eventType = json_string_value(type);

if (strcmp(eventType,"Seismic") == 0) {
json_t *subType = json_object_get(value,"subtype");
if ((subType != NULL) && (strcmp("MultiplePEER_Event",json_string_value(subType)) ==0)) {

json_t *index = json_object_get(value,"index");

if (json_is_integer(index) == false) {
const char *eventName = json_string_value(index);

// we need to replace the EVENT with another event
json_t *inputEvent = json_array_get(inputEventsArray,count);
json_t *events = json_object_get(inputEvent,"Events");
for (int i=0; i<json_array_size(events); i++) {
json_t *theEvent = json_array_get(events, i);
const char * name = json_string_value(json_object_get(theEvent,"name"));

if (strcmp(eventName, name) == 0) {
addEvent(name, value);
i = json_array_size(events);
}
}
}
json_t *eventObj = json_object();
}
json_t *subType = json_object_get(value,"subtype");
if ((subType != NULL) && (strcmp("MultiplePEER_Event",json_string_value(subType)) ==0)) {

json_t *index = json_object_get(value,"index");

if (json_is_integer(index) == false) {
const char *eventName = json_string_value(index);

// we need to replace the EVENT with another event
json_t *inputEvent = json_array_get(inputEventsArray,count);
json_t *events = json_object_get(inputEvent,"Events");
for (int i=0; i<json_array_size(events); i++) {
json_t *theEvent = json_array_get(events, i);
const char * name = json_string_value(json_object_get(theEvent,"name"));

if (strcmp(eventName, name) == 0) {
addEvent(name, value);
i = json_array_size(events);
}
}
}
json_t *eventObj = json_object();
}
}
}
// write rootEvent
Expand Down
32 changes: 16 additions & 16 deletions modules/createSAM/openSeesInput/OpenSeesInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ main(int argc, char **argv) {
if (fileName == 0) { // not passed in input, should be in AIM
json_t *theApplications = json_object_get(rootAIM,"Applications");
if (theApplications == NULL) {
fprintf(stderr, "AIM file missing Applications");
exit(-1);
fprintf(stderr, "AIM file missing Applications");
exit(-1);
}
json_t *theModeling = json_object_get(theApplications,"Modeling");
if (theModeling == NULL) {
fprintf(stderr, "AIM file Applications missing Modeling");
exit(-1);
fprintf(stderr, "AIM file Applications missing Modeling");
exit(-1);
}
json_t *theAppData = json_object_get(theModeling,"ApplicationData");
if (theAppData == NULL) {
fprintf(stderr, "AIM file Applications missing AppData");
exit(-1);
fprintf(stderr, "AIM file Applications missing AppData");
exit(-1);
}
json_t *theFileName = json_object_get(theAppData,"fileName");
if (theFileName == NULL && !json_is_string(theFileName)) {
fprintf(stderr, "AIM file AppData missing fileName");
exit(-1);
fprintf(stderr, "AIM file AppData missing fileName");
exit(-1);
}
const char *fileName2 = json_string_value(theFileName);
length = json_string_length(theFileName);
Expand Down Expand Up @@ -130,14 +130,14 @@ main(int argc, char **argv) {
floor = 0; // ground floor floor 0

json_array_foreach(theCentroidNodes, index, intObj) {
json_t *nodeEntry =json_object();
int tag = json_integer_value(intObj);
json_object_set(nodeEntry,"node",json_integer(tag));
json_object_set(nodeEntry,"cline",json_string("centroid"));
sprintf(floorString,"%d",floor);
json_object_set(nodeEntry,"floor",json_string(floorString));
floor++;
json_array_append(mappingArray, nodeEntry);
json_t *nodeEntry =json_object();
int tag = json_integer_value(intObj);
json_object_set(nodeEntry,"node",json_integer(tag));
json_object_set(nodeEntry,"cline",json_string("centroid"));
sprintf(floorString,"%d",floor);
json_object_set(nodeEntry,"floor",json_string(floorString));
floor++;
json_array_append(mappingArray, nodeEntry);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ simcenter_add_python_script(SCRIPT ScenarioForecast.py)
simcenter_add_python_script(SCRIPT liquefaction.py)
simcenter_add_python_script(SCRIPT landslide.py)
simcenter_add_python_script(SCRIPT GMSimulators.py)
simcenter_add_python_script(SCRIPT GlobalVariable.py)
Loading

0 comments on commit 05759d6

Please sign in to comment.