|
|
# Howto: Deterministic Inversion with AD #
|
|
|
Here you find a step, by step intoduction howto create a Input File for using ``ad`` mode, similar to [Howto: Forward computation](./howto_forward). This mode uses Automatic Differentiation.
|
|
|
Here you find a step, by step introduction howto create a Input File for using ``ad`` mode, similar to [Howto: Forward computation](./howto_forward). This mode uses Automatic Differentiation.
|
|
|
|
|
|
For a in depth description of all key-words look at [Deterministic Inversion Input](../tutorial/deterministic_inversion_input)
|
|
|
|
|
|
For internal users the pages Determenistic Inversion Output and Inversion Code Workflow may also be interresting.
|
|
|
For internal users the pages Deterministic Inversion Output and Inversion Code Workflow may also be interesting.
|
|
|
|
|
|
## Table of Contents
|
|
|
[[_TOC_]]
|
|
|
|
|
|
# Compilation
|
|
|
At first you need to create a excecuteable wich was compiled with flag ``ad``. Therfore you have to checkout your SHEMAT-Suite repository like this:
|
|
|
At first you need to create a executable which was compiled with flag ``ad``. Therefore you have to checkout your SHEMAT-Suite repository like this:
|
|
|
```
|
|
|
git checkout master-all
|
|
|
```
|
|
|
Now you can compile your excecuteable. Best practice is to use a [Compilation Shell Script](../tutorial/compilation#compilation-shell-script), wich combines all necessary steps. One can be found in the SHEMAT-Suite_Modells repository: [compilequick.sh](https://git.rwth-aachen.de/SHEMAT-Suite/SHEMAT-Suite_Models/blob/master/compilequick.sh). Here you have to set ``shem_type="ad"``. For this tutorial you have to set ``shem_type="ad"``, ``mode="head" ``, ``props="const"``, ``user="none"``, ``compiler_name="ifort"``, ``flags="-Dhdf=ON -Domp=OFF -j16"`` Also make sure to change `model_dir` and `make_dir` to your personal directories. Maybe you should create a new model directory for this tutorial.
|
|
|
|
|
|
Now you can compile your executable. Best practice is to use a [Compilation Shell Script](../tutorial/compilation#compilation-shell-script), which combines all necessary steps. One can be found in the SHEMAT-Suite_Models repository: [compilequick.sh](https://git.rwth-aachen.de/SHEMAT-Suite/SHEMAT-Suite_Models/blob/master/compilequick.sh). Here you have to set ``shem_type="ad"``. For this tutorial you have to set ``shem_type="ad"``, ``mode="head" ``, ``props="const"``, ``user="none"``, ``compiler_name="ifort"``, ``flags="-Dhdf=ON -Domp=OFF -j16"`` Also make sure to change `model_dir` and `make_dir` to your personal directories. Maybe you should create a new model directory for this tutorial.
|
|
|
```
|
|
|
./compilequick.sh
|
|
|
```
|
... | ... | @@ -21,11 +22,11 @@ Now ``shem_ad_ifort_const_none_head_master-all_quick.x`` is in your model direct |
|
|
|
|
|
# Creating Input File
|
|
|
## Run Forward Model
|
|
|
At first you need a model, wich you want to calculate a deterministic inversion for. In this tutorial we will use [oed_perth_init](uploads/9a7000f5eb0967ceaac204ea54a3548f/oed_perth_init). With all existing key-words you should be familiar, if not you may first should take a look at [Howto: Forward computation](./howto_forward), where a example Input File is created. If you want to look up specific key-words go to [Input File](../tutorial/input_file). Copy ``oed_perth_init`` in your modell directory. Make sure the repository contains a file named ``shemade.job`` wich only contains the model name: ``oed_perth_init``.
|
|
|
At first you need a model, which you want to calculate a deterministic inversion for. In this tutorial we will use [oed_perth_init](uploads/9a7000f5eb0967ceaac204ea54a3548f/oed_perth_init). With all existing key-words you should be familiar, if not you may first should take a look at [Howto: Forward computation](./howto_forward), where a example Input File is created. If you want to look up specific key-words go to [Input File](../tutorial/input_file). Copy ``oed_perth_init`` in your model directory. Make sure the repository contains a file named ``shemade.job`` which only contains the model name: ``oed_perth_init``.
|
|
|
```
|
|
|
./shem_ad_ifort_const_none_head_master-all_quick.x > out.txt
|
|
|
```
|
|
|
The values of this solution will be used as starting values for the deterministic inversion. For the the next steps you will only need ``oed_perth_init_final.h5``, ``shemade.job``, ``oed_perth_init`` and the executeable, maybe you should create a new subfolder and cut all other files there.
|
|
|
The values of this solution will be used as starting values for the deterministic inversion. For the the next steps you will only need ``oed_perth_init_final.h5``, ``shemade.job``, ``oed_perth_init`` and the executable, maybe you should create a new sub-folder and cut all other files there.
|
|
|
|
|
|
## Create AD Input File
|
|
|
Now you need to add some keywords to the Input File to create an AD Input File. You also need to adjust some boundary conditions. At first change the name of the Input File ``oed_perth_init`` to ``oed_inv`` and change ``# runmode`` from ``0`` to ``2``. You also have to change the name in ``shemade.job`` to the new Input File name.
|
... | ... | @@ -40,7 +41,7 @@ Next you should set boundary conditions for the ``head`` variable. Got to ``!=== |
|
|
# head bcd, simple=right, value=init
|
|
|
# head bcd, simple=left, bcindex=1
|
|
|
```
|
|
|
Go to ``!==========>>>>> define boundariy properties`` and also remove the ``!``, so that SHEMAT reads the boundary condtition for the head variable. Don't forget to change the number of records to ``3``.
|
|
|
Go to ``!==========>>>>> define boundary properties`` and also remove the ``!``, so that SHEMAT reads the boundary condition for the head variable. Don't forget to change the number of records to ``3``.
|
|
|
```
|
|
|
1 3005 head
|
|
|
```
|
... | ... | @@ -87,9 +88,9 @@ Here the 4th property, permeability in z-direction, is enabled as logarithmic (` |
|
|
0.0 0.0 0.0 6.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
|
|
|
0.0 0.0 0.0 6.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
|
|
|
```
|
|
|
With this key-word the apriori variance of each unit-property is defined. In this case the permeability in z-direction of all units is given a variance of 6. If the parameter is set to logarithmic in ``# enable property`` you have to set the variance for the logarithmic converted parameter here. All other properties don´t have a variance and will be constant. This variance can be understood as weighting factor of the minimizing funktion. The higher the value, the more changes will appear in that specific unit.
|
|
|
With this key-word the apriori variance of each unit-property is defined. In this case the permeability in z-direction of all units is given a variance of 6. If the parameter is set to logarithmic in ``# enable property`` you have to set the variance for the logarithmic converted parameter here. All other properties don´t have a variance and will be constant. This variance can be understood as weighting factor of the minimizing function. The higher the value, the more changes will appear in that specific unit.
|
|
|
|
|
|
In this modell only the permeability in z-direction, of unit 5 is enabled, as logarithmic, for deterministic inversion.
|
|
|
In this model only the permeability in z-direction, of unit 5 is enabled, as logarithmic, for deterministic inversion.
|
|
|
|
|
|
#### # inverse
|
|
|
```
|
... | ... | @@ -100,11 +101,11 @@ In this modell only the permeability in z-direction, of unit 5 is enabled, as lo |
|
|
1
|
|
|
```
|
|
|
The meaning of the numbers is described from top to bottom. ``1`` does not have a meaning, it should always be set to 1.
|
|
|
The next line defines the break-off critirea: ``5 0.0001`` The maximum number of iterations is set with ``5``. If the difference between two iteration steps is below ``0.0001`` it stops at that point.
|
|
|
The next entry ``0 0`` disables computation of the resolution matrix and computation of the covariance matrix. The last entry ``1`` defines the output frequency. It means that the results of every calculated iteration will be saved in a sepereate file. If you are not interrested in these iterrations replace ``1`` with 5 or a greater number. The calculation results will be saved in seperate files anyway.
|
|
|
The next line defines the break-off criteria: ``5 0.0001`` The maximum number of iterations is set with ``5``. If the difference between two iteration steps is below ``0.0001`` it stops at that point.
|
|
|
The next entry ``0 0`` disables computation of the resolution matrix and computation of the covariance matrix. The last entry ``1`` defines the output frequency. It means that the results of every calculated iteration will be saved in a separate file. If you are not interested in these iterations replace ``1`` with 5 or a greater number. The calculation results will be saved in separate files anyway.
|
|
|
|
|
|
#### # data
|
|
|
With this key-word you add observed/measured data. For a runmode greater or equal to 1 this input is expected. The first column, wich starts with ``23.7769395446154`` defines the data value. It is followed by the error, wich is ``0.5`` for all records. I don`t know what the error is used for. The next three entries are the position, the order is x, y, z: ``180 1 59``. It is followed by pv-type, the type index for the physical value, ``2`` stands for temperature. The last entry ``1`` (index of observation zone) does not matter in this example.
|
|
|
With this key-word you add observed/measured data. For a runmode greater or equal to 1 this input is expected. The first column, which starts with ``23.7769395446154`` defines the data value. It is followed by the error, which is ``0.5`` for all records. I don`t know what the error is used for. The next three entries are the position, the order is x, y, z: ``180 1 59``. It is followed by pv-type, the type index for the physical value, ``2`` stands for temperature. The last entry ``1`` (index of observation zone) does not matter in this example.
|
|
|
```
|
|
|
# data, records=39
|
|
|
23.7769395446154 0.5 180 1 59 2 1
|
... | ... | @@ -148,7 +149,7 @@ With this key-word you add observed/measured data. For a runmode greater or equa |
|
|
108.260490155576 0.5 180 1 21 2 1
|
|
|
```
|
|
|
# Execution
|
|
|
You finished your first Determenistic Inversion Input File, execute it. Make sure your working directory contains the files ``shemade.job``, ``oed_inv``, ``oed_perth_init_final.h5`` and the executeable.
|
|
|
You finished your first Deterministic Inversion Input File, execute it. Make sure your working directory contains the files ``shemade.job``, ``oed_inv``, ``oed_perth_init_final.h5`` and the executable.
|
|
|
```
|
|
|
./shem_ad_ifort_const_none_head_master-all_quick.x > out.txt
|
|
|
``` |