DOI: 10.5281/zenodo.6970739
title: Diffusion models with time-dependent parameters: "An analysis of computational effort and accuracy of different numerical methods"

description: Software repository for the reproduction of the test cases from <strong>Thomas Richter, Rolf Ulrich, Markus Janczyk:</strong> <em>Diffusion models with time-dependent parameters: "An analysis of computational effort and accuracy of different numerical methods"</em> This software is used in particular for the reproducibility of the results. However, the algorithms can also be used directly for own purposes. If you have any questions about possibly necessary adaptations, please contact thomas.richter@ovgu.de. Parts of this repository General setup <strong>Python</strong> collects all Python script. Here, <strong>Python/PythonTools</strong> are several internal functions, e.g. the realizations of KFE and random walks. <strong>Python/results</strong> and <strong>Python/pics</strong> are the directories where the results (figures and text-files) are put. <strong>C++</strong> collects the C++ scripts. Case I Reproduces Case I of the paper (time-independent) Python/TestCase1.py runs the test-case with random walks, integral equation method and with KFE. It produces output in <strong>Python/pics</strong> and <strong>Python/results</strong>. These results will be used in <strong>C++/testcase1.cc</strong> (as reference solution) and by <strong>Python/TestCase1-Plot.py</strong> C++/testcase1.cc runs the stochastic Euler simulation. Script is started by <strong>C++/run-testcase1.sh</strong>. It reads in the reference solution generated by <strong>Python/TestCase1.py</strong> for computing errors. Python/TestCase1-Plot.py produces Fig. 6 of the paper. It requires the outputs of <strong>Python/TestCase1.py</strong> and <strong>C++/testcase1.cc</strong> Case II Reproduces Case II of the paper (time-dependent thresholds and drift) Python/TestCase2.py runs the test-case with random walks, integral equation method and with KFE. It produces output in <strong>Python/pics</strong> and <strong>Python/results</strong>. These results will be used in <strong>C++/testcase2.cc</strong> (as reference solution) and by <strong>Python/TestCase2-Plot.py</strong> C++/testcase2.cc runs the stochastic Euler simulation. Script is started by <strong>C++/run-testcase2.sh</strong>. It reads in the reference solution generated by <strong>Python/TestCase2.py</strong> for computing errors. Python/TestCase2-Plot.py produces Fig. 7 of the paper. It requires the outputs of <strong>Python/TestCase2.py</strong> and <strong>C++/testcase2.cc</strong> Python/TestCase2-AdjustRandomWalks.py runs simulations to reproduce Fig. 11 of the paper and implements the modification of the random walk strategy to limit oscillations. Case III Reproduces Case III of the paper (dependency of the accuracy on the derivative of the drift) Python/TestCase3.py runs the test-case with random walks, integral equation method and with KFE for a fixed discretization but with different values of the drift tau. It produces first part of Fig. 8. C++/testcase3.cc runs the stochastic Euler simulation. Script is started by <strong>C++/run-testcase3.sh</strong>. It reads in the reference solution generated by <strong>Python/TestCase3.py</strong> for computing errors. Python/TestCase3-Plot.py produces second part of Fig. 8. Depends on the output of <strong>Python/TestCase3.py</strong> Case IV Reproduces Case IV of the paper (accuracy and efficiency for Dirac initial data) Python/TestCase4.py runs the test-case with random walks, integral equation and with KFE for a refined discretizations. Python/TestCase4-Plot.py produces Fig. 9. Depends on the output of <strong>Python/TestCase4.py</strong> Python/TestCase4-showsolution.py Solves with the KFE and plots the solution as surface plot over time and space variable. This skript is used to create Fig. 10 of the paper. Problem parameters and discretization can be adjusted at the top of the script. To test the different stabilization strategies, one can either adjust the value of theta, or one activates Rannacher time-marching by commenting in the marked lines in the skript PythonTools/kfe.py, here in kfe_ale(..) Data Fitting Python scripts to fit the KFE model to the Data published by Rolf Ulrich et al. in <strong>R. Ulrich, H. Schröter, H. Leuthold, T. Birngruber</strong> <em>Automatic and controlled stimulus processing in conflict tasks: Superimposed diffusion processes and delta functions.</em>Cognitive Psychology, 78 , 148–174 Python/DataFitting-Simon.py runs the parameter fitting for the Simon task and produces data for Fig. 9 and Table 1. Python/Eriksen-Fletcher.py runs the parameter fitting for the Eriksen Fletcher task and produces data for Fig. 9 and Table 2. Installation & running the examples Python The python skripts can just be started. Just note that they depend on each other, i.e.: <strong>Python/TestCase1.py</strong> produces a reference solution that is required by <strong>C++/testcase1.cc</strong> and the results of both are needed in <strong>Python/TestCase1-Plot.py</strong> The scripts only depend on standard packages like numpy or scipy and all Python environments should work. One suggestion is to use Spyder as part of Anaconda. C++ The C++-programs are not intended for performing the simulations in a stand-alone application. Instead, the SDE is simulated for a given number of trials <strong>N_tr</strong> and a given time step <strong>dt</strong> and this simulation is repeated <strong>64</strong> times in order to estimate the average error. It should however be simple to use the scripts as basis for an efficient parallel simulation tool that uses multithreading. Configuration The C++ test cases must be compiled. The test cases are set up to use <strong>cmake</strong>. We suggest the following (in a Linux-environment or on a Mac using homebrew or MacPorts): Create a directory for compilation, e.g. <strong>C++/bin</strong> now called the <strong>bin-dir</strong> In the <strong>bin-dir</strong> calls cmake by <strong>cmake ..</strong> (adjust the path, if the <strong>bin-dir</strong> is not a subdirectory of the <strong>C++-dir</strong>. Several options can be adjusted. In <strong>C++/bin</strong> call <strong>ccmake .</strong> to make all necessary changes. If you change the location of the <strong>bin-dir</strong> you will have to modify the run-scripts <strong>run-testcase[123].sh</strong>. Compilation Initially and whenever you change the code, the programs must be re-compiled In <strong>C++/bin</strong> just call <strong>make</strong> Running the examples The programs are started in <strong>C++</strong>. For each of the test-case there is a skript to start the program. In <strong>C++</strong> call <strong>sh ./run-testcase1.sh</strong> (or <strong>sh ./run-testcase2.sh</strong>, etc.) Each script will start the programs several times. For <strong>Case I</strong>, <strong>Case II</strong> and <strong>Case IV</strong> the simulation is started on a sequence of finer and finer discretizations, for <strong>Case III</strong> the value of <em>tau</em> will be changed. The scripts store the output in <strong>C++/results</strong>. Old outputs will be overwritten! Further, the scripts read information about the reference solution from <strong>Python/resuts</strong>. The C++ programs use multithreading the OpenMP. If you do not specify the number of threads to be used, all available threads are taken including all hyperthreads. This is usually not efficient it is therefore advisable to set the number of threads by hand, e.g. by calling <strong>export OMP_NUM_THREADS=8</strong> before calling the run-scripts. License Information Initially the software has been written Thomas Richter, Otto-von-Guericke University Magdeburg, Germany in 2022, 2023 (thomas.richter@ovgu.de) You are free to use the scripts under the <em>Creative Commons Attribution 4.0 License</em>.
description: Software to reproduce the results from the paper Thomas Richter, Markus Janczyk, Rolf Ulrich: Diffusion models with time-dependent parameters: "Analysis and computational effort and accuracy of different numerical methods"