Skip to content

Commit

Permalink
Updated the simulation part to accomodate new reciprocal setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lsawade committed Jan 25, 2024
1 parent 82a08ab commit 2cdcd0f
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/gf3d/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Simulation:

def __init__(
self,
specfemdir,
specfemdir: str,
stationdir: str | None = None,
station_latitude: float | None = None,
station_longitude: float | None = None,
Expand All @@ -42,6 +42,7 @@ def __init__(
ndt: None | float = None,
lpfilter: str = 'butter',
forward_test: bool = False,
forwardspecfemdir: str | None = None,
forwardoutdir: str | None = None,
broadcast_mesh_model: bool = False,
simultaneous_runs: bool = False,
Expand Down Expand Up @@ -170,6 +171,7 @@ def __init__(

self.specfemdir = specfemdir
self.stationdir = stationdir
self.forwardspecfemdir = forwardspecfemdir
self.forwardoutdir = forwardoutdir
self.station_latitude = station_latitude # degree
self.station_longitude = station_longitude # degree
Expand Down Expand Up @@ -271,7 +273,7 @@ def create_specfem(self):
--exclude='obj/*' \
--exclude='bin/*' \
--delete \
{self.specfemdir}/ {self.specfemdir_forward}"""
{self.forwardspecfemdir}/ {self.specfemdir_forward}"""

subprocess.check_call(copytreecmd, shell=True)

Expand Down Expand Up @@ -322,6 +324,43 @@ def create(self):
os.symlink(BINS_SOURCE, BINS_TARGET)

# Create Write all the files
if self.forward_test:

# Remove pre-existing directory
if (os.path.exists(self.specfemdir_forward) and self.overwrite) or \
not os.path.exists(self.specfemdir_forward):

subprocess.check_call(f'rm -rf {self.specfemdir_forward}', shell=True)

# Make dir
os.makedirs(self.specfemdir_forward)

# DATA DIR
DATADIR = os.path.join(self.specfemdir_forward, 'DATA')
os.makedirs(DATADIR)

# OUTPUT DIR
OUTPUT_DIR = os.path.join(self.specfemdir_forward, 'OUTPUT_FILES')
os.makedirs(OUTPUT_DIR)

if self.simultaneous_runs is False:

# Link DATABASES
DATABASES_MPI_SOURCE = os.path.join(
self.forwardspecfemdir, "DATABASES_MPI")
DATABASES_MPI_TARGET = os.path.join(
self.specfemdir_forward, "DATABASES_MPI")

os.symlink(DATABASES_MPI_SOURCE, DATABASES_MPI_TARGET)

# Link BINs
BINS_SOURCE = os.path.join(
self.forwardspecfemdir, "bin")
BINS_TARGET = os.path.join(
self.specfemdir_forward, "bin")

os.symlink(BINS_SOURCE, BINS_TARGET)


# Write Rotation files
self.logger.debug('Updating constants.h.in ...')
Expand Down

0 comments on commit 2cdcd0f

Please sign in to comment.