diff --git a/CHANGELOG b/CHANGELOG index eb33b5bc087db0ca861ee6232499ce6a04cfdb55..dcc10ecc0017ded1e08cb4e93be3b628c8b20815 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/Depthprobe1.py b/Examples/varia/Depthprobe1.py index a9531300399da68192ff4e01d52aff44426cd4ff..af325d05308da8a7f6ea86fdc3a47453277580c1 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 0000000000000000000000000000000000000000..d2f578331e172c339772d7fa38fa114b6803ee55 --- /dev/null +++ b/Examples/varia/TransmittedModulus.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +""" +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__': + flags = ba.ZDirection_Transmitted | ba.WaveProperty_Modulus + dp1.run_example(flags) diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index f65844848388817193892712f648f1bc16379cfe..7698ff4153f9b6cb8bc0f8362a164bdc43e2f9bb 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 a92f16773db273848fdf2d1ef1e573bce1abf63c..837ebc9eb917132c62fc3d74da65cfb3ddfa7793 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/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt index 2c45011d822d872cd0e054d6847b445c02404c01..44ef32d6f71996332feeac0d8a546a6c5572d42e 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 Binary files /dev/null and b/Tests/ReferenceData/ExamplesMini/varia/TransmittedModulus.int.gz differ diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py index fb632e0286b301778bd01c247619bbcff3ffcdf0..f7ef1cb82c46ef9ecf961c6e94d7655b34599948 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 65662e37947a7e7a728f3823053677a9612a233b..d78f0377b60edc47576c7094789d26edf9941c03 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 diff --git a/hugo/content/ex/sim/depthprobe/_index.md b/hugo/content/ex/sim/depthprobe/_index.md index 5256aabe2ed194cf3a54febe7c3a55bfd97afc81..1a870257b874969f1a0473cce65807ebe3cfab6e 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 0000000000000000000000000000000000000000..fa63fcae36b09b1b5651640c528267fbd84fe410 --- /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 3e2e833a223c207afdd01b377217dcc4404cca07..ba46d9977049d8b19ed9119011ed72f44aa72f17 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)