forked from NDF-Poli-USP/spyro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Olender/issue_0041
Add first part of the code of elastic wave propagation. It is still incomplete, but include some code refactoring that may be used by other branches.
- Loading branch information
Showing
24 changed files
with
397 additions
and
1,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from abc import abstractmethod | ||
|
||
from ..wave import Wave | ||
|
||
class ElasticWave(Wave): | ||
'''Base class for elastic wave propagators''' | ||
def __init__(self, dictionary, comm=None): | ||
super().__init__(dictionary, comm=comm) | ||
|
||
#@override | ||
def _initialize_model_parameters(self): | ||
d = self.input_dictionary.get("synthetic_data", False) | ||
if bool(d) and "type" in d: | ||
if d["type"] == "object": | ||
self.initialize_model_parameters_from_object(d) | ||
elif d["type"] == "file": | ||
self.initialize_model_parameters_from_file(d) | ||
else: | ||
raise Exception(f"Invalid synthetic data type: {d['type']}") | ||
else: | ||
raise Exception("Input dictionary must contain ['synthetic_data']['type']") | ||
|
||
@abstractmethod | ||
def initialize_model_parameters_from_object(self, synthetic_data_dict): | ||
pass | ||
|
||
@abstractmethod | ||
def initialize_model_parameters_from_file(self, synthetic_data_dict): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from .elastic_wave import ElasticWave | ||
|
||
class IsotropicWave(ElasticWave): | ||
'''Isotropic elastic wave propagator''' | ||
def __init__(self, dictionary, comm=None): | ||
super().__init__(dictionary, comm=comm) | ||
|
||
self.rho = None # Density | ||
self.lmbda = None # First Lame parameter | ||
self.mu = None # Second Lame parameter | ||
self.c_s = None # Secondary wave velocity | ||
|
||
#@override | ||
def initialize_model_parameters_from_object(self, synthetic_data_dict: dict): | ||
self.rho = synthetic_data_dict.get("density", None) | ||
self.lmbda = synthetic_data_dict.get("lambda", | ||
synthetic_data_dict.get("lame_first", None)) | ||
self.mu = synthetic_data_dict.get("mu", | ||
synthetic_data_dict.get("lame_second", None)) | ||
self.c = synthetic_data_dict.get("p_wave_velocity", None) | ||
self.c_s = synthetic_data_dict.get("s_wave_velocity", None) | ||
|
||
# Check if {rho, lambda, mu} is set and {c, c_s} are not | ||
option_1 = bool(self.rho) and \ | ||
bool(self.lmbda) and \ | ||
bool(self.mu) and \ | ||
not bool(self.c) and \ | ||
not bool(self.c_s) | ||
# Check if {rho, c, c_s} is set and {lambda, mu} are not | ||
option_2 = bool(self.rho) and \ | ||
bool(self.c) and \ | ||
bool(self.c_s) and \ | ||
not bool(self.lmbda) and \ | ||
not bool(self.mu) | ||
|
||
if not option_1 and not option_2: | ||
raise Exception(f"Inconsistent selection of isotropic elastic wave parameters:\n" \ | ||
f" Density : {bool(self.rho)}\n"\ | ||
f" Lame first : {bool(self.lmbda)}\n"\ | ||
f" Lame second : {bool(self.mu)}\n"\ | ||
f" P-wave velocity: {bool(self.c)}\n"\ | ||
f" S-wave velocity: {bool(self.c_s)}\n"\ | ||
"The valid options are \{Density, Lame first, Lame second\} "\ | ||
"or \{Density, P-wave velocity, S-wave velocity\}") | ||
|
||
#@override | ||
def initialize_model_parameters_from_file(self, synthetic_data_dict): | ||
raise NotImplementedError |
Oops, something went wrong.