Skip to content

Commit

Permalink
Modified jbsim Python codes to use jbsim 3.0.0 and set flag when usin…
Browse files Browse the repository at this point in the history
…g complete GFs.
  • Loading branch information
fabiolsilva committed Nov 12, 2024
1 parent 3c1d862 commit 3b71644
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
23 changes: 17 additions & 6 deletions bbp/comps/jbsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
BSD 3-Clause License
Copyright (c) 2023, University of Southern California
Copyright (c) 2024, University of Southern California
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -78,9 +78,18 @@ def run(self):
a_statfile = os.path.join(install.A_IN_DATA_DIR,
str(sim_id),
self.r_stations)
a_srffile = os.path.join(install.A_IN_DATA_DIR,
str(sim_id),
self.r_srffile)
a_rupture_file = os.path.join(install.A_IN_DATA_DIR,
str(sim_id),
self.r_srffile)
# RWG 20241025: jbsim-v3.0.0 is backward compatible with jbsim-v2.0.0
# it can use rupture files in both SRF and MRF formats
if os.path.splitext(a_rupture_file)[-1].lower() == ".srf":
rupmod_type = "SRF"
elif os.path.splitext(a_rupture_file)[-1].lower() == ".mrf":
rupmod_type = "MRF"
else:
print("[ERROR]: Unknown rupture format in file %s" % (a_rupture_file))
sys.exit(-1)

# Set directories, and make sure they exist
a_indir = os.path.join(install.A_IN_DATA_DIR, str(sim_id))
Expand All @@ -106,9 +115,11 @@ def run(self):
#
progstring = ("%s latloncoords=1 slon=%f slat=%f " %
(os.path.join(install.A_GP_BIN_DIR,
"jbsim-v2.0.0"), slon, slat) +
"jbsim-v3.0.0"), slon, slat) +
"tshift_timedomain=1 use_closest_gf=1 " +
"rupmodtype=SRF rupmodfile=%s " % a_srffile +
"cgf_flag=%d " % (config.GF_CGFFLAG) +
"rupmodtype=%s " % (rupmod_type) +
"rupmodfile=%s " % (a_rupture_file) +
"moment=-1 outdir=%s stat=%s " % (a_veldir, site) +
"min_taper_range=0.0 max_taper_range=0.0 " +
"gftype=fk gflocs=%s gftimes=%s gf_swap_bytes=%d " %
Expand Down
9 changes: 7 additions & 2 deletions bbp/comps/jbsim_cfg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
BSD 3-Clause License
Copyright (c) 2021, University of Southern California
Copyright (c) 2024, University of Southern California
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -93,6 +93,11 @@ def __init__(self, vmodel_name):
self.NTOUT = int(vmodel_params['NTOUT'])
else:
self.NTOUT = 4096
# RWG 20241025: Added parameter GF_CGFFLAG
if 'GF_CGFFLAG' in vmodel_params:
self.GF_CGFFLAG = int(vmodel_params['GF_CGFFLAG'])
else:
self.GF_CGFFLAG = 0

# Now, configure other paramteres
self.GF_SWAP_BYTES = 0
Expand Down

0 comments on commit 3b71644

Please sign in to comment.