The code is implemented in the following parts:
Diffusion.py
: Runs the simulation and generates the results in a directory calleddiffusion_res
Constants_Diff.py
: Includes all of the settings and connstants required for the model.Diff_combine.py
: Combines the results in the folderResults_Combine
and saves them toCombined_Plots
create_state_values.py
: Not to be run, helper to create states when no external input is given.
First of all, one needs to have Python to run the code. The version used to test the code is 3.8.5. The Python directory along with the scripts directory need to be added to the environment variables to directly run commands from the terminal.
Then, the package dependencies need to be installed. The versions that the codes were run with are also provided, but they do not need to be exactly the same. These are the package dependencies:
- numpy - v1.22.1
- matplotlib - v3.3.4
- tqdm - v0.0.1
- scipy - v1.5.2
To install a package, use the command pip install <package>=<version>
on your terminal.
To run the code:
- Change settings on
Constants_Diff.py
if needed. - Run
Diffusion.py
, output will be generated ondiffusion_res
directory. - Create a directory
Results_Combine
if not created yet. - Move the
diffusion_res
directory toResults_Combine
, renamediffusion_res
to your scenario name to be seen in the plots. - Repeat this process from steps 1-4 until all required scenario results are generated.
- Run
Diff_combine.py
, the comparison results will be onCombined_Plots
.
The settings can be found in the file Constants_Diff.py
. The file includes the settings on receiver, transmitter, the environment and the molecule counts. The simulation precision can be modified from the simulation parameters. The way the membrane states are initialized can be modified, or the membrane states can be provided externally.
- Nanomachine Properties: In this part, the TX and RX radii are defined.
- Diffusion Settings: In this part, the diffusion and permeability coefficients on the medium and the membrane are defined. The opening and closing of the membrane can be made noninstantaneous if the parameter
p_close
is set to a positive value. - Environment Properties: These are the properties for the environment or the channel, such as degradation and TX-RX distance.
- Reaction Rate Constants: These constants are the experimentally found reaction rate constants for the (R)-Mandelate to (S)-Mandelate reaction. Not to be modified.
- Molecule Counts: Defined as an object for the inside and outside. Changing the first parameter of the
Particle
objects for the inside or the outside will change the corresponding initial molecule counts. - Simulation Parameters:
step_count
andsimulation_end
can be changed.step_count
will determine the number of total steps in the simulation, so it defines the precision.simulation_end
determines the total simulation time. - States: The states are an array with the length of
step_count
. In the settings, a way to define this array is provided by the parameters.release_count
is the number of releases,end_part
is the part after which the TX stays closed. The releases are distributed evenly, but that can be changed by changingstate_breaks
. Note that in this part the simulation is considered of length 1, soend_part=0.5
means the TX will stay closed in the second half of the simulation.