From d735cd658c726728aae8224ddbd4f225f10cf0d6 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 31 Mar 2023 11:53:38 +0200
Subject: [PATCH 1/3] DpSim: + flags for partical beams, for amplitude modulus
 and phase

---
 Sim/Simulation/DepthprobeSimulation.cpp |  28 +++-
 Sim/Simulation/DepthprobeSimulation.h   |  11 +-
 auto/Wrap/libBornAgainSim.py            |  13 +-
 auto/Wrap/libBornAgainSim_wrap.cpp      | 207 +++++++++++++++++++++++-
 4 files changed, 249 insertions(+), 10 deletions(-)

diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp
index f6584484838..7698ff4153f 100644
--- a/Sim/Simulation/DepthprobeSimulation.cpp
+++ b/Sim/Simulation/DepthprobeSimulation.cpp
@@ -32,11 +32,19 @@
 #include <iostream>
 #include <valarray>
 
+const int ZDirection_None = 0;
+const int ZDirection_Reflected = 1;
+const int ZDirection_Transmitted = 2;
+const int WaveProperty_Intensity = 0;
+const int WaveProperty_Modulus = 4;
+const int WaveProperty_Phase = 8;
+
 DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample,
-                                           const IAxis& zaxis)
+                                           const IAxis& zaxis, int flags)
     : ISimulation(sample)
     , m_scan(dynamic_cast<AlphaScan*>(scan.clone()))
     , m_z_axis(zaxis.clone())
+    , m_flags(flags)
 {
     if (!m_scan)
         throw std::runtime_error("DepthprobeSimulation not implemented for non-alpha scan");
@@ -115,7 +123,23 @@ void DepthprobeSimulation::runComputation(const ReSample& re_sample, size_t i, d
                 if (i_layer + 1 != n_layers && (*m_z_axis)[i_z] <= z_layer_bottom)
                     break;
                 const double z = (*m_z_axis)[i_z] - z_layer_top;
-                intensities[i_z] = std::norm(R * exp_I(kz_out * z) + T * exp_I(kz_in * z));
+                complex_t psi;
+                if ((m_flags & 3) == ZDirection_None)
+                    psi = R * exp_I(kz_out * z) + T * exp_I(kz_in * z);
+                else if (m_flags & ZDirection_Reflected)
+                    psi = R * exp_I(kz_out * z);
+                else if (m_flags & ZDirection_Transmitted)
+                    psi = T * exp_I(kz_in * z);
+                else
+                    throw std::runtime_error("Invalid combination of ZDirection flags");
+                if ((m_flags & 12) == WaveProperty_Intensity)
+                    intensities[i_z] = std::norm(psi);
+                else if (m_flags & WaveProperty_Modulus)
+                    intensities[i_z] = std::abs(psi);
+                else if (m_flags & WaveProperty_Phase)
+                    intensities[i_z] = std::arg(psi);
+                else
+                    throw std::runtime_error("Invalid combination of WaveProperty flags");
             }
             start_z_ind = ip1_z;
         }
diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h
index a92f16773db..fb750cfbc1a 100644
--- a/Sim/Simulation/DepthprobeSimulation.h
+++ b/Sim/Simulation/DepthprobeSimulation.h
@@ -22,6 +22,13 @@ class IAxis;
 class IBeamScan;
 class IFootprintFactor;
 
+extern const int ZDirection_None;
+extern const int ZDirection_Reflected;
+extern const int ZDirection_Transmitted;
+extern const int WaveProperty_Intensity;
+extern const int WaveProperty_Modulus;
+extern const int WaveProperty_Phase;
+
 //! Simulation of radiation depth profile.
 //!
 //! Holds an instrument and sample model.
@@ -31,7 +38,8 @@ class IFootprintFactor;
 
 class DepthprobeSimulation : public ISimulation {
 public:
-    DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample, const IAxis& zaxis);
+    DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample, const IAxis& zaxis,
+        int flags = 0);
     ~DepthprobeSimulation() override;
 
     std::string className() const final { return "DepthprobeSimulation"; }
@@ -71,6 +79,7 @@ private:
     //... Model components:
     std::unique_ptr<AlphaScan> m_scan;
     std::unique_ptr<IAxis> m_z_axis;
+    const int m_flags;
 #endif // SWIG
 };
 
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index fb632e0286b..f7ef1cb82c4 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -2725,9 +2725,9 @@ class DepthprobeSimulation(ISimulation):
     thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
     __repr__ = _swig_repr
 
-    def __init__(self, scan, sample, zaxis):
-        r"""__init__(DepthprobeSimulation self, IBeamScan scan, MultiLayer const & sample, IAxis zaxis) -> DepthprobeSimulation"""
-        _libBornAgainSim.DepthprobeSimulation_swiginit(self, _libBornAgainSim.new_DepthprobeSimulation(scan, sample, zaxis))
+    def __init__(self, scan, sample, zaxis, flags=0):
+        r"""__init__(DepthprobeSimulation self, IBeamScan scan, MultiLayer const & sample, IAxis zaxis, int flags=0) -> DepthprobeSimulation"""
+        _libBornAgainSim.DepthprobeSimulation_swiginit(self, _libBornAgainSim.new_DepthprobeSimulation(scan, sample, zaxis, flags))
     __swig_destroy__ = _libBornAgainSim.delete_DepthprobeSimulation
 
     def className(self):
@@ -2736,6 +2736,13 @@ class DepthprobeSimulation(ISimulation):
 
 # Register DepthprobeSimulation in _libBornAgainSim:
 _libBornAgainSim.DepthprobeSimulation_swigregister(DepthprobeSimulation)
+ZDirection_None = cvar.ZDirection_None
+ZDirection_Reflected = cvar.ZDirection_Reflected
+ZDirection_Transmitted = cvar.ZDirection_Transmitted
+WaveProperty_Intensity = cvar.WaveProperty_Intensity
+WaveProperty_Modulus = cvar.WaveProperty_Modulus
+WaveProperty_Phase = cvar.WaveProperty_Phase
+
 class SpecularSimulation(ISimulation):
     r"""Proxy of C++ SpecularSimulation class."""
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index 65662e37947..d78f0377b60 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -33395,7 +33395,145 @@ SWIGINTERN PyObject *ScatteringSimulation_swiginit(PyObject *SWIGUNUSEDPARM(self
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_new_DepthprobeSimulation(PyObject *self, PyObject *args) {
+SWIGINTERN int Swig_var_ZDirection_None_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable ZDirection_None is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_ZDirection_None_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(ZDirection_None));
+  return pyobj;
+}
+
+
+SWIGINTERN int Swig_var_ZDirection_Reflected_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable ZDirection_Reflected is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_ZDirection_Reflected_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(ZDirection_Reflected));
+  return pyobj;
+}
+
+
+SWIGINTERN int Swig_var_ZDirection_Transmitted_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable ZDirection_Transmitted is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_ZDirection_Transmitted_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(ZDirection_Transmitted));
+  return pyobj;
+}
+
+
+SWIGINTERN int Swig_var_WaveProperty_Intensity_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable WaveProperty_Intensity is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_WaveProperty_Intensity_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(WaveProperty_Intensity));
+  return pyobj;
+}
+
+
+SWIGINTERN int Swig_var_WaveProperty_Modulus_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable WaveProperty_Modulus is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_WaveProperty_Modulus_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(WaveProperty_Modulus));
+  return pyobj;
+}
+
+
+SWIGINTERN int Swig_var_WaveProperty_Phase_set(PyObject *) {
+  SWIG_Error(SWIG_AttributeError,"Variable WaveProperty_Phase is read-only.");
+  return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_WaveProperty_Phase_get(void) {
+  PyObject *pyobj = 0;
+  
+  pyobj = SWIG_From_int(static_cast< int >(WaveProperty_Phase));
+  return pyobj;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_DepthprobeSimulation__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  IBeamScan *arg1 = 0 ;
+  MultiLayer *arg2 = 0 ;
+  IAxis *arg3 = 0 ;
+  int arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  int val4 ;
+  int ecode4 = 0 ;
+  DepthprobeSimulation *result = 0 ;
+  
+  if ((nobjs < 4) || (nobjs > 4)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_IBeamScan,  0  | 0);
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DepthprobeSimulation" "', argument " "1"" of type '" "IBeamScan const &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DepthprobeSimulation" "', argument " "1"" of type '" "IBeamScan const &""'"); 
+  }
+  arg1 = reinterpret_cast< IBeamScan * >(argp1);
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_MultiLayer,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_DepthprobeSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DepthprobeSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+  }
+  arg2 = reinterpret_cast< MultiLayer * >(argp2);
+  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IAxis,  0  | 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_DepthprobeSimulation" "', argument " "3"" of type '" "IAxis const &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DepthprobeSimulation" "', argument " "3"" of type '" "IAxis const &""'"); 
+  }
+  arg3 = reinterpret_cast< IAxis * >(argp3);
+  ecode4 = SWIG_AsVal_int(swig_obj[3], &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_DepthprobeSimulation" "', argument " "4"" of type '" "int""'");
+  } 
+  arg4 = static_cast< int >(val4);
+  result = (DepthprobeSimulation *)new DepthprobeSimulation((IBeamScan const &)*arg1,(MultiLayer const &)*arg2,(IAxis const &)*arg3,arg4);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DepthprobeSimulation, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_DepthprobeSimulation__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   IBeamScan *arg1 = 0 ;
   MultiLayer *arg2 = 0 ;
@@ -33406,10 +33544,9 @@ SWIGINTERN PyObject *_wrap_new_DepthprobeSimulation(PyObject *self, PyObject *ar
   int res2 = 0 ;
   void *argp3 = 0 ;
   int res3 = 0 ;
-  PyObject *swig_obj[3] ;
   DepthprobeSimulation *result = 0 ;
   
-  if (!SWIG_Python_UnpackTuple(args, "new_DepthprobeSimulation", 3, 3, swig_obj)) SWIG_fail;
+  if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_IBeamScan,  0  | 0);
   if (!SWIG_IsOK(res1)) {
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DepthprobeSimulation" "', argument " "1"" of type '" "IBeamScan const &""'"); 
@@ -33442,6 +33579,62 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_new_DepthprobeSimulation(PyObject *self, PyObject *args) {
+  Py_ssize_t argc;
+  PyObject *argv[5] = {
+    0
+  };
+  
+  if (!(argc = SWIG_Python_UnpackTuple(args, "new_DepthprobeSimulation", 0, 4, argv))) SWIG_fail;
+  --argc;
+  if (argc == 3) {
+    int _v = 0;
+    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_IBeamScan, SWIG_POINTER_NO_NULL | 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_MultiLayer, SWIG_POINTER_NO_NULL | 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_IAxis, SWIG_POINTER_NO_NULL | 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_new_DepthprobeSimulation__SWIG_1(self, argc, argv);
+        }
+      }
+    }
+  }
+  if (argc == 4) {
+    int _v = 0;
+    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_IBeamScan, SWIG_POINTER_NO_NULL | 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_MultiLayer, SWIG_POINTER_NO_NULL | 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_IAxis, SWIG_POINTER_NO_NULL | 0);
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          {
+            int res = SWIG_AsVal_int(argv[3], NULL);
+            _v = SWIG_CheckState(res);
+          }
+          if (_v) {
+            return _wrap_new_DepthprobeSimulation__SWIG_0(self, argc, argv);
+          }
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_DepthprobeSimulation'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    DepthprobeSimulation::DepthprobeSimulation(IBeamScan const &,MultiLayer const &,IAxis const &,int)\n"
+    "    DepthprobeSimulation::DepthprobeSimulation(IBeamScan const &,MultiLayer const &,IAxis const &)\n");
+  return 0;
+}
+
+
 SWIGINTERN PyObject *_wrap_delete_DepthprobeSimulation(PyObject *self, PyObject *args) {
   PyObject *resultobj = 0;
   DepthprobeSimulation *arg1 = (DepthprobeSimulation *) 0 ;
@@ -36156,7 +36349,7 @@ static PyMethodDef SwigMethods[] = {
 	 { "ScatteringSimulation_detector", _wrap_ScatteringSimulation_detector, METH_O, "ScatteringSimulation_detector(ScatteringSimulation self) -> IDetector &"},
 	 { "ScatteringSimulation_swigregister", ScatteringSimulation_swigregister, METH_O, NULL},
 	 { "ScatteringSimulation_swiginit", ScatteringSimulation_swiginit, METH_VARARGS, NULL},
-	 { "new_DepthprobeSimulation", _wrap_new_DepthprobeSimulation, METH_VARARGS, "new_DepthprobeSimulation(IBeamScan scan, MultiLayer const & sample, IAxis zaxis) -> DepthprobeSimulation"},
+	 { "new_DepthprobeSimulation", _wrap_new_DepthprobeSimulation, METH_VARARGS, "DepthprobeSimulation(IBeamScan scan, MultiLayer const & sample, IAxis zaxis, int flags=0)"},
 	 { "delete_DepthprobeSimulation", _wrap_delete_DepthprobeSimulation, METH_O, "delete_DepthprobeSimulation(DepthprobeSimulation self)"},
 	 { "DepthprobeSimulation_className", _wrap_DepthprobeSimulation_className, METH_O, "DepthprobeSimulation_className(DepthprobeSimulation self) -> std::string"},
 	 { "DepthprobeSimulation_swigregister", DepthprobeSimulation_swigregister, METH_O, NULL},
@@ -37200,6 +37393,12 @@ SWIG_init(void) {
   PyDict_SetItemString(md, "cvar", globals);
   SWIG_addvarlink(globals, "major_version_number", Swig_var_major_version_number_get, Swig_var_major_version_number_set);
   SWIG_addvarlink(globals, "minor_version_number", Swig_var_minor_version_number_get, Swig_var_minor_version_number_set);
+  SWIG_addvarlink(globals, "ZDirection_None", Swig_var_ZDirection_None_get, Swig_var_ZDirection_None_set);
+  SWIG_addvarlink(globals, "ZDirection_Reflected", Swig_var_ZDirection_Reflected_get, Swig_var_ZDirection_Reflected_set);
+  SWIG_addvarlink(globals, "ZDirection_Transmitted", Swig_var_ZDirection_Transmitted_get, Swig_var_ZDirection_Transmitted_set);
+  SWIG_addvarlink(globals, "WaveProperty_Intensity", Swig_var_WaveProperty_Intensity_get, Swig_var_WaveProperty_Intensity_set);
+  SWIG_addvarlink(globals, "WaveProperty_Modulus", Swig_var_WaveProperty_Modulus_get, Swig_var_WaveProperty_Modulus_set);
+  SWIG_addvarlink(globals, "WaveProperty_Phase", Swig_var_WaveProperty_Phase_get, Swig_var_WaveProperty_Phase_set);
 #if PY_VERSION_HEX >= 0x03000000
   return m;
 #else
-- 
GitLab


From dbfcc62d18e640ac897d6c1cf57a35b8ecf61e6d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 31 Mar 2023 13:38:21 +0200
Subject: [PATCH 2/3] DepthprobeSimulation can now return intensity, modulus,
 phase of total, reflected, transmitted field

---
 Examples/varia/Depthprobe1.py                   |  12 +++++++-----
 Examples/varia/TransmittedModulus.py            |  11 +++++++++++
 Sim/Simulation/DepthprobeSimulation.h           |   2 +-
 Tests/Examples/CMakeLists.txt                   |   1 +
 .../varia/TransmittedModulus.int.gz             | Bin 0 -> 11531 bytes
 5 files changed, 20 insertions(+), 6 deletions(-)
 create mode 100755 Examples/varia/TransmittedModulus.py
 create mode 100644 Tests/ReferenceData/ExamplesMini/varia/TransmittedModulus.int.gz

diff --git a/Examples/varia/Depthprobe1.py b/Examples/varia/Depthprobe1.py
index a9531300399..af325d05308 100755
--- a/Examples/varia/Depthprobe1.py
+++ b/Examples/varia/Depthprobe1.py
@@ -22,21 +22,23 @@ def get_sample():
     return sample
 
 
-def get_simulation(sample):
+def get_simulation(sample, flags):
     n = bp.simargs['n']
 
     scan = ba.AlphaScan(n, 0*deg, 1*deg)
     scan.setWavelength(0.3*nm)
 
     z_axis = ba.FixedBinAxis("z", n, -130*nm, 30*nm)
-    simulation = ba.DepthprobeSimulation(scan, sample, z_axis)
+    simulation = ba.DepthprobeSimulation(scan, sample, z_axis, flags)
 
     return simulation
 
-
-if __name__ == '__main__':
+def run_example(flags=0):
     bp.parse_args(sim_n=500, aspect='auto', intensity_max=1e2, intensity_min=1e-12)
     sample = get_sample()
-    simulation = get_simulation(sample)
+    simulation = get_simulation(sample, flags)
     result = simulation.simulate()
     bp.plot_simulation_result(result)
+
+if __name__ == '__main__':
+    run_example()
diff --git a/Examples/varia/TransmittedModulus.py b/Examples/varia/TransmittedModulus.py
new file mode 100755
index 00000000000..320b42d170c
--- /dev/null
+++ b/Examples/varia/TransmittedModulus.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+"""
+Basic example of depth-probe simulation:
+Computes intensity as function of incident angle alpha and depth z.
+"""
+
+import bornagain as ba
+import Depthprobe1 as dp1
+
+if __name__ == '__main__':
+    dp1.run_example(ba.ZDirection_Transmitted | ba.WaveProperty_Modulus)
diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h
index fb750cfbc1a..837ebc9eb91 100644
--- a/Sim/Simulation/DepthprobeSimulation.h
+++ b/Sim/Simulation/DepthprobeSimulation.h
@@ -39,7 +39,7 @@ extern const int WaveProperty_Phase;
 class DepthprobeSimulation : public ISimulation {
 public:
     DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample, const IAxis& zaxis,
-        int flags = 0);
+                         int flags = 0);
     ~DepthprobeSimulation() override;
 
     std::string className() const final { return "DepthprobeSimulation"; }
diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt
index 2c45011d822..44ef32d6f71 100644
--- a/Tests/Examples/CMakeLists.txt
+++ b/Tests/Examples/CMakeLists.txt
@@ -218,6 +218,7 @@ run_example(specular/PolarizedSpinAsymmetry)
 run_example(specular/PolarizedSpinFlip)
 
 test_example1d(varia/Depthprobe1 2e-10)
+test_example1d(varia/TransmittedModulus 2e-10)
 test_example1d(varia/Resonator 2e-10)
 test_example1d(varia/OffspecSimulation 2e-10)
 test_example1d(varia/AccessingSimulationResults 2e-10)
diff --git a/Tests/ReferenceData/ExamplesMini/varia/TransmittedModulus.int.gz b/Tests/ReferenceData/ExamplesMini/varia/TransmittedModulus.int.gz
new file mode 100644
index 0000000000000000000000000000000000000000..97fc66b6f1ee4b4202c017e7a1bb880104da00b5
GIT binary patch
literal 11531
zcmYLvbx>SSur-=R7k76HF2P|JhlSu4+%>^9xclNRiv)KI5F{bEEw)&I5Zn?%aQ*nb
z?^V6~*R8tu%$)A&In~qCbO{(p|MNVb7EaYLze_9JzvkdsC&JVN+&|kdC*dFPV~G<8
zbA)vR>N}V2Cf7Sx!iq3}Hj0G)TiUj7=9oU-Z%kz6atl6>$UN_cJQw#r|9ieW-h6u6
ze}1^{f4;fze>~lM{!{$?*!cXkB=dB$P51n89P)6w`NZ+~SLW%8PUh*-{ORgC1o8aH
z`y9&uIB5QKa>yI<q!Un)ac<(+sdrw*GKIJ^f69=W(egBH?f7BeDEPeOIrdO&A|R7J
zsrTG4CjHp>KzN`0Z+|32?eOj6t)UDe<<k1`x%H{pj5|s9xXyd&YP;BDu)v&q-_(Q0
zv4Yci$k+^AZ>FSS-S*e;*tyX-u+jf0L=y3rQX;7++RbfeB+tBSq3g2KbNb`Et~%$b
zzTw|pyXS_-Tr&%Z>ASu*I_HqZ(ne$N8Q1==b^qEg-Ut?(w%&Lv)!Tj&5By{J&wD-V
z+^lR-65&_(FB730m{=FmI8x)CW9locgQ&DsUm}S-@;>>ryS&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ject: [PATCH 3/3] document transmitted modulus example

---
 CHANGELOG                                     |  5 +++
 Examples/varia/TransmittedModulus.py          |  8 +++--
 hugo/content/ex/sim/depthprobe/_index.md      |  1 +
 .../ex/sim/depthprobe/transmitted_modulus.md  | 18 ++++++++++
 .../content/ref/sim/class/depthprobe/index.md | 33 +++++++++++++++++--
 5 files changed, 60 insertions(+), 5 deletions(-)
 create mode 100644 hugo/content/ex/sim/depthprobe/transmitted_modulus.md

diff --git a/CHANGELOG b/CHANGELOG
index eb33b5bc087..dcc10ecc001 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+BornAgain-21.0, in preparation
+  > New functionality:
+    * DepthprobeSimulation can be parameterized through flags to return intensity,
+      modulus, or phase of the total, transmitted, or reflected wave field.
+
 BornAgain-20.0, released 2023.03.27
   > Contributors:
     * Current maintainers: Ammar Nejati, Mikhail Svechnikov, Joachim Wuttke
diff --git a/Examples/varia/TransmittedModulus.py b/Examples/varia/TransmittedModulus.py
index 320b42d170c..d2f578331e1 100755
--- a/Examples/varia/TransmittedModulus.py
+++ b/Examples/varia/TransmittedModulus.py
@@ -1,11 +1,13 @@
 #!/usr/bin/env python3
 """
-Basic example of depth-probe simulation:
-Computes intensity as function of incident angle alpha and depth z.
+Thin-film sample as in basic depth-probe example.
+Computes modulus of amplitude of transmitted field
+as function of of incident angle alpha and depth z.
 """
 
 import bornagain as ba
 import Depthprobe1 as dp1
 
 if __name__ == '__main__':
-    dp1.run_example(ba.ZDirection_Transmitted | ba.WaveProperty_Modulus)
+    flags = ba.ZDirection_Transmitted | ba.WaveProperty_Modulus
+    dp1.run_example(flags)
diff --git a/hugo/content/ex/sim/depthprobe/_index.md b/hugo/content/ex/sim/depthprobe/_index.md
index 5256aabe2ed..1a870257b87 100644
--- a/hugo/content/ex/sim/depthprobe/_index.md
+++ b/hugo/content/ex/sim/depthprobe/_index.md
@@ -12,4 +12,5 @@ Class reference:
 
 Examples
 - [Basic example: thin film on substrate](/ex/sim/depthprobe/depthprobe1)
+- [Transmitted amplitude modulus](/ex/sim/depthprobe/transmitted_modulus)
 - [Resonator](/ex/sim/depthprobe/resonator)
diff --git a/hugo/content/ex/sim/depthprobe/transmitted_modulus.md b/hugo/content/ex/sim/depthprobe/transmitted_modulus.md
new file mode 100644
index 00000000000..fa63fcae36b
--- /dev/null
+++ b/hugo/content/ex/sim/depthprobe/transmitted_modulus.md
@@ -0,0 +1,18 @@
++++
+title = "Transmitted modulus"
+weight = 10
++++
+
+## Transmitted modulus
+
+Modulus of the amplitude of the partial wave field propagating in
+transmission direction,
+as function of depth and incident angle $\alpha_i$.
+
+Same sample as in the previous [basic example](depthprobe1),
+a thin film on a substrate.
+
+
+{{< figscg src="/img/auto/varia/TransmittedModulus.png" width="500" class="center">}}
+
+{{< highlightfile file="Examples/varia/TransmittedModulus.py" >}}
diff --git a/hugo/content/ref/sim/class/depthprobe/index.md b/hugo/content/ref/sim/class/depthprobe/index.md
index 3e2e833a223..ba46d997704 100644
--- a/hugo/content/ref/sim/class/depthprobe/index.md
+++ b/hugo/content/ref/sim/class/depthprobe/index.md
@@ -9,7 +9,10 @@ Depth probe simulation is an auxiliary simulation type, which helps to visualize
 the total intensity in dependence on the beam incidence angle and the position in
 the sample.
 
-To set up and run a simulation, use
+#### Compute intensity
+
+To compute the total wave intensity as function of $\alpha_\text{i}$ and z,
+use
 ```python
 import bornagain as ba
 scan = ...
@@ -28,6 +31,32 @@ For optional settings, see [simulation options](/ref/sim/setup/options).
 For the return type of function `simulate()`,
 see [SimulationResult](/ref/sim/simulation-result).
 
-Examples:
+#### Partial waves, modulus, phase
+
+The constructor takes an optional `flags` argument
+```
+simulation = ba.DepthprobeSimulation(scan, sample, z_axis, flags)
+```
+
+Flags may designate a partial beam
+```
+ba.ZDirection_None        # = 0, may be ommitted: total field
+ba.ZDirection_Reflected   # reflected beam only
+ba.ZDirection_Transmitted # transmitted beam only
+```
+or/and a property of the simulated wave field
+```
+ba.WaveProperty_Intensity # = 0, may be ommitted: intensity, |psi|^2
+ba.WaveProperty_Modulus   # modulus of wave amplitude, |psi|
+ba.WaveProperty_Phase     # phase of wave amplitude, arg(psi), in rad
+```
+To combine flags from each of these groups, combine them with the "or" operator:
+```
+flags = ba.ZDirection_Reflected | ba.WaveProperty_Modulus
+```
+
+#### Examples
+
 - [Basic example: thin film on substrate](/ex/sim/depthprobe/depthprobe1)
+- [Transmitted amplitude modulus](/ex/sim/depthprobe/transmitted_modulus)
 - [Resonator](/ex/sim/depthprobe/resonator)
-- 
GitLab