Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/Workflow/whale/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ def preprocess_inputs( # noqa: C901
# This time, (1) we do it only for python; (2) added try statement

try:
if command.startswith('python'):
if command.startswith('python') and self.run_type == 'set_up':
if platform.system() == 'Windows':
driver_script += 'if %errorlevel% neq 0 exit /b -1 \n' #TODO ANYONE: This variable is not defined. Check This please. (Added by Sina)
else:
Expand Down Expand Up @@ -2461,7 +2461,7 @@ def create_driver_file( # noqa: C901
# This time, (1) we do it only for python; (2) added try statement

# try:
if 'python' in command_list[0].lower():
if 'python' in command_list[0].lower() and self.run_type == 'set_up':
if platform.system() == 'Windows':
driver_script += 'if %errorlevel% neq 0 exit /b -1 \n'
else:
Expand Down
32 changes: 27 additions & 5 deletions modules/createEVENT/IsolatedBuildingCFD/IsolatedBuildingCFD.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ def scale_event(filename_aim, filename_event):
except (json.JSONDecodeError, IOError) as e:
print(f"Error IsolatedBuilldingCFD::scale_event processing files: {e}")


def GetFloorsCount(BIMFilePath): # noqa: N802, N803, D103
with open(BIMFilePath) as BIMFile: # noqa: PTH123, N806
bim = json.load(BIMFile)

return int(bim['GeneralInformation']['stories'])


if __name__ == "__main__":
"""
Expand All @@ -366,17 +371,34 @@ def scale_event(filename_aim, filename_event):
parser.add_argument("--getRV", action="store_true", help="used to get random variable, if not multiply EVENT by gs")


# #parsing arguments
# arguments, unknowns = parser.parse_known_args()

# # [forcesOutputName, floors, startTime, lengthScale, velocityScale] = ReadBIM(arguments.bim)

# # GetOpenFOAMEvent(arguments.case, forcesOutputName, floors, startTime, lengthScale, velocityScale)

# if not arguments.getRV:

# scale_event(filename_aim = arguments.filenameAIM, filename_event = arguments.filenameEVENT)

#parsing arguments
arguments, unknowns = parser.parse_known_args()

# [forcesOutputName, floors, startTime, lengthScale, velocityScale] = ReadBIM(arguments.bim)

# GetOpenFOAMEvent(arguments.case, forcesOutputName, floors, startTime, lengthScale, velocityScale)
if arguments.getRV == True: # noqa: E712
# Read the number of floors
# floorsCount = GetFloorsCount(arguments.filenameAIM) # noqa: N816
floorsCount = GetFloorsCount(arguments.filenameAIM) # noqa: N816
forces = []
for i in range(floorsCount): # noqa: B007
forces.append(FloorForces()) # noqa: PERF401
# write the event file
writeEVENT(forces, arguments.filenameEVENT)

if not arguments.getRV:

scale_event(filename_aim = arguments.filenameAIM, filename_event = arguments.filenameEVENT)





20 changes: 10 additions & 10 deletions modules/createEVENT/stochasticWave/Jonswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

input_args = sys.argv[1:]

print( # noqa: T201
'Jonswap.py - Backend-script post_process_sensors.py running: '
+ str(sys.argv[0])
)
print( # noqa: T201
'post_process_sensors.py - Backend-script post_process_sensors.py received input args: '
+ str(input_args)
)
# print( # noqa: T201
# 'Jonswap.py - Backend-script post_process_sensors.py running: '
# + str(sys.argv[0])
# )
# print( # noqa: T201
# 'post_process_sensors.py - Backend-script post_process_sensors.py received input args: '
# + str(input_args)
# )

inputFile = sys.argv[1] # noqa: N816
outputPath = sys.argv[2] # noqa: N816
Expand All @@ -47,7 +47,7 @@
with open(inputFile, encoding='utf-8') as BIMFile: # noqa: PTH123
bim = json.load(BIMFile)
for event_id in range(1):
print('Running a sample simulation with JSON input parameters') # noqa: T201
# print('Running a sample simulation with JSON input parameters') # noqa: T201
g = 9.80665 # gravity [m/s^2]
rho = 1000.0 # water density

Expand Down Expand Up @@ -165,7 +165,7 @@

# if (si == seeds[-1]):

print('Saving wave spectra and time series') # noqa: T201
# print('Saving wave spectra and time series') # noqa: T201
spectra_df = pd.DataFrame()

spectra_df['Frequency'] = freq
Expand Down
12 changes: 6 additions & 6 deletions modules/createEVENT/stochasticWave/StochasticWave.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def readRV(aimFilePath='AIM.json', eventFilePath='EVENT.json'): # noqa: D103, N
addFloorForceToEvent(
timeSeriesArray, patternsArray, floorForces.X, 'X', floor, deltaT
)
addFloorForceToEvent(
timeSeriesArray, patternsArray, floorForces.Y, 'Y', floor, deltaT
)
# addFloorForceToEvent(
# timeSeriesArray, patternsArray, floorForces.Y, 'Y', floor, deltaT
# )
addFloorPressure(pressureArray, floor)

eventDict['Events'].append(event_json)
Expand Down Expand Up @@ -237,9 +237,9 @@ def writeEVENT(forces, eventFilePath, deltaT=1.0): # noqa: D103, N802, N803
addFloorForceToEvent(
timeSeriesArray, patternsArray, floorForces.X, 'X', floor, deltaT
)
addFloorForceToEvent(
timeSeriesArray, patternsArray, floorForces.Y, 'Y', floor, deltaT
)
# addFloorForceToEvent(
# timeSeriesArray, patternsArray, floorForces.Y, 'Y', floor, deltaT
# )
addFloorPressure(pressureArray, floor)

with open(eventFilePath, 'w', encoding='utf-8') as f: # noqa: PTH123
Expand Down
4 changes: 2 additions & 2 deletions modules/performFEM/surrogateGP/gpPredict.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from scipy.stats import lognorm, norm
from sklearn.linear_model import LinearRegression

errFileName = os.path.join(os.getcwd(), 'workflow.err') # noqa: N816, PTH109, PTH118
sys.stderr = open(errFileName, 'a') # noqa: SIM115, PTH123
# errFileName = os.path.join(os.getcwd(), 'workflow.err') # noqa: N816, PTH109, PTH118
# sys.stderr = open(errFileName, 'a') # noqa: SIM115, PTH123

try:
moduleName = 'GPy' # noqa: N816
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ def create_event(asset_file: str, event_grid_file: str, workflow_input: str, do_
# open input file & get Regional Event data
#

# candidate paths
json_path = os.path.join(os.getcwd(), workflow_input)

with open(json_path, 'r') as f:
data = json.load(f)
if not os.path.exists(json_path):
json_path = os.path.join(os.path.dirname(os.getcwd()), workflow_input)

if os.path.isfile(json_path):
with open(json_path, 'r') as f:
data = json.load(f)
else:
raise FileNotFoundError(f"Could not find {workflow_input} in current or parent directory")

regional_event = data.get("RegionalEvent")

Expand Down
8 changes: 4 additions & 4 deletions modules/performUQ/common/extractEDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(int argc, const char **argv)
int numValues = json_array_size(sType);
for (int i=0; i<numValues; i++) {
double value = json_number_value(json_array_get(sType,i));
printf("%f ", value);
// FMK printf("%f ", value);
fOut << value << " ";
numEDP++;
}
Expand All @@ -54,7 +54,7 @@ int main(int argc, const char **argv)
int numValues = json_array_size(sType);
for (int i=0; i<numValues; i++) {
double value = json_number_value(json_array_get(sType,i));
printf("%f ", value);
// printf("%f ", value);
fOut << value << " ";
numEDP++;
}
Expand All @@ -68,15 +68,15 @@ int main(int argc, const char **argv)
int numValues = json_array_size(sType);
for (int i=0; i<numValues; i++) {
double value = json_number_value(json_array_get(sType,i));
printf("%f ", value);
// printf("%f ", value);
fOut << value << " ";
numEDP++;
}
}
}
}

printf("NUM_EDP= %d\n",numEDP);
// printf("NUM_EDP= %d\n",numEDP);

fOut.close();

Expand Down
2 changes: 2 additions & 0 deletions modules/performUQ/dakota/postprocessDakota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ void processEDPs(const char* filenameEDP, const char* dakotaOUT, int numRV, int
}
}

/* fmk
for (int i=0; i<numSample; i++) {
for (int j=0; j<numEDP; j++) {
printf("%f ", data[i*numEDP+j]);
}
printf("\n");
}
*/

json_dump_file(root,filenameEDP,0);
}
Expand Down
44 changes: 35 additions & 9 deletions modules/performUQ/dakota/simCenterDprepro.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
#include <deque>
#include <iterator>

using std::string;
using std::vector;
using std::deque;

/* ***************** params.in example ******
{ DAKOTA_VARS = 2 }
Expand Down Expand Up @@ -47,14 +47,15 @@ int main(int argc, char **argv)
}

//
// vectors that will contain strinmgs to search for & their replacement
// deques that will contain strinmgs to search for & their replacement
//

vector<string> original;
vector<string> replace;
vector<int> originalLength;
vector<int> replacementLength;

deque<string> original;
deque<string> replace;
deque<int> originalLength;
deque<int> replacementLength;
deque<string> rvNames; // original string of random variable names

//
// from params file, 1) read # of RV and 2) then read RV names and values
//
Expand All @@ -63,6 +64,8 @@ int main(int argc, char **argv)
int numRVs = 0;
string line;
while (getline(params, line)) {


std::istringstream buf(line);
std::istream_iterator<std::string> beg(buf), end;
vector<std::string> tokens(beg, end); // done!
Expand All @@ -75,12 +78,35 @@ int main(int argc, char **argv)
} else {

// subsequent lines contain RV and value .. add to string vectors
string rvName = "\"RV." + tokens.at(1) + "\""; // add SimCenter delimiters begin="RV. & end="
string rvName = tokens.at(1); // add SimCenter delimiters begin="RV. &\ end="
string rvValue = tokens.at(3);
// check if an existing rvName starts as a substring of current
bool subStringExists = false;
for (size_t i = 0; i < rvNames.size(); ++i) {
const std::string& s1 = rvName[i];
if (rvName.find(s1) == 0) {
subStringExists = true;
break; // No need to check further if found
}
}
}

if (subStringExists == false) {
rvNames.push_back(rvName);
rvName = "\"RV." + rvName + "\""; // add SimCenter delimiters begin="RV. &\ end="
original.push_back(rvName);
replace.push_back(rvValue);
originalLength.push_back(rvName.length());
replacementLength.push_back(rvValue.length());

} else {
rvNames.push_front(rvName);
rvName = "\"RV." + rvName + "\"";
replace.push_front(rvValue);
originalLength.push_front(rvName.length());
replacementLength.push_front(rvValue.length());

}
// std::cerr << rvName << " " << rvValue << "\n";
}

Expand Down
Loading