From 892a17a60d9250df8af1a571b03933ad8ab37bb7 Mon Sep 17 00:00:00 2001 From: Rohit Kakodkar Date: Wed, 17 Jul 2024 10:55:49 -0400 Subject: [PATCH] Added Network name and station name checks for adjoint sources - Updated documentation - Added runtime error exception if network name and station name is not defined - Updated cookbook for example 3 --- .gitignore | 3 + docs/cookbooks/example_03.rst | 4 +- .../source_description/source_discription.rst | 99 +++++++++++++++++++ src/source/read_sources.cpp | 4 + 4 files changed, 109 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 61573f3c..90fae8a6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ examples/*/Par_File *.sqlite *.nsys-rep *.ncu-rep +.snakemake* +autotuning* +*snakemake* diff --git a/docs/cookbooks/example_03.rst b/docs/cookbooks/example_03.rst index 8b063767..3eba7868 100644 --- a/docs/cookbooks/example_03.rst +++ b/docs/cookbooks/example_03.rst @@ -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 @@ -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 diff --git a/docs/source_description/source_discription.rst b/docs/source_description/source_discription.rst index 13246461..34bd60c8 100644 --- a/docs/source_description/source_discription.rst +++ b/docs/source_description/source_discription.rst @@ -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 diff --git a/src/source/read_sources.cpp b/src/source/read_sources.cpp index 99dd8200..5ff14fda 100644 --- a/src/source/read_sources.cpp +++ b/src/source/read_sources.cpp @@ -50,6 +50,10 @@ specfem::sources::read_sources( sources.push_back(std::make_shared( 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( adjoint_node, nsteps, dt)); } else {