Skip to content

Commit

Permalink
Added Network name and station name checks for adjoint sources
Browse files Browse the repository at this point in the history
- Updated documentation
- Added runtime error exception if network name and station name is not defined
- Updated cookbook for example 3
  • Loading branch information
Rohit-Kakodkar committed Jul 17, 2024
1 parent b4afd5f commit 892a17a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ examples/*/Par_File
*.sqlite
*.nsys-rep
*.ncu-rep
.snakemake*
autotuning*
*snakemake*
4 changes: 3 additions & 1 deletion docs/cookbooks/example_03.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Now finally we can run the adjoint simulation. We use the same mesh database as
f0: 0.42
- adjoint-source:
station_name: AA
network_name: S0001
x: 150000
z: 40000
source_surf: false
Expand All @@ -338,7 +340,7 @@ Now finally we can run the adjoint simulation. We use the same mesh database as
format: ascii
stf-file: /scratch/gpfs/rk9481/specfem2d_kokkos/examples/Tromp_2005/OUTPUT_FILES/AA.S0001
2. To set up the a combined simulation, we need to replace the forward YAML node with a combined node.
1. To set up the a combined simulation, we need to replace the forward YAML node with a combined node.

.. code-block:: yaml
:caption: combined YAML node
Expand Down
99 changes: 99 additions & 0 deletions docs/source_description/source_discription.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,102 @@ Moment Tensor Source Description
factor: 1e10
tshift: 0.0
f0: 1.0
Adjoint Source Description
==========================

**Parameter Name** : ``sources.adjoint-source``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [YAML Node]

**Description** : Definition of adjoint source

**Parameter Name** : ``sources.adjoint-source.station_name``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [string]

**Description** : Name of the station.

**Parameter Name** : ``sources.adjoint-source.network_name``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [string]

**Description** : Name of the network.

**Parameter Name** : ``sources.adjoint-source.x``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [float]

**Description** : X coordinate location of the adjoint source.

**Parameter Name** : ``sources.adjoint-source.z``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [float]

**Description** : Z coordinate location of the adjoint source.

**Parameter Name** : ``sources.adjoint-source.angle`` [optional]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : 0.0

**possible values** : [float]

**Description** : Angle of the adjoint source.

**Parameter Name** : ``sources.adjoint-source.Dirac`` [optional]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [YAML Node]

**Description** : Definition of Dirac source :ref:`dirac_source_description`

**Parameter Name** : ``sources.adjoint-source.Ricker`` [optional]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [YAML Node]

**Description** : Definition of Ricker source :ref:`ricker_source_description`

**Parameter Name** : ``sources.adjoint-source.External`` [optional]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**dafault value** : None

**possible values** : [YAML Node]

**Description** : Definition of External source :ref:`external_source_description`


.. admonition:: Example

.. code-block:: yaml
adjoint-source:
station_name: AA
network_name: S0001
x: 0.0
z: 0.0
angle: 0.0
Dirac:
factor: 1e10
tshift: 0.0
4 changes: 4 additions & 0 deletions src/source/read_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ specfem::sources::read_sources(
sources.push_back(std::make_shared<specfem::sources::external>(
external_source, nsteps, dt, source_wavefield_type));
} else if (YAML::Node adjoint_node = N["adjoint-source"]) {
if (!adjoint_node["station_name"] || !adjoint_node["network_name"]) {
throw std::runtime_error(
"Station name and network name are required for adjoint source");
}
sources.push_back(std::make_shared<specfem::sources::adjoint_source>(
adjoint_node, nsteps, dt));
} else {
Expand Down

0 comments on commit 892a17a

Please sign in to comment.