VERB_code_2.3
EPSS/VERB/verb-2-0/verb2-examples/1D Radial Diffusion (2004)/README.md
1 # Description
2 
3 
4 The folder contains all of the functions needed to reproduce the plots observed in the 2004 paper (same name as this directory).
5 
6 
7 ## HOW IT WORKS
8 
9 The program runs in the following order:
10 
11  1. SETUP: The `setup.m` script runs with the parameters that you determine inside the script (discussed below).
12 
13  2. RUN (optional): If you opted to run the simulation, the .exe program (VERB_CODE_2.0) will perform the simulation using Parameters_x.ini as a set of guidelines.
14 
15  3. PLOT (optional): If you opted to plot the results, the script `Plot.m` will display your results, and you can choose to save the plot in the Figures folder.
16 
17 ## HOW TO USE
18 
19 Very simply, you only need to run the `setup.m` script to run the program and plot the results!
20 
21 ______________________________________________
22 
23 ### SETUP
24 
25 Within the `setup.m` file, the first thing you will see are four (4) PARAMETERS that you must set: OS, FIGURE, RUN, and PLOT.
26 
27 OS - specify which operating system you are using so it will run the proper executable file.
28 
29 FIGURE - specify which Figure from the paper you want to re-create (Figure 5 cannot be reproduced).
30 
31 RUN - decide if you want to actually run the executable (if you previously ran the simulation on the same figure, it will be unnecessary since you already have the results).
32 
33 PLOT - decide if you want to plot the results of your data (results are stored in the Output folder and read into `Plot.m` from there).
34 
35 An example of this may look like:
36 
37  OS = 'MAC';
38  FIGURE = '3';
39  RUN = true;
40  PLOT = false;
41 
42 
43 This will all be re-explained inside `setup.m`, where you will run the program.
44 
45 ### RUN
46 
47 This folder only contains the VERB_code_2.0.exe file. For more information on how the simulation code actually runs, look into the [VERB 2.0](http://ysgit.epss.ucla.edu/verb/verb-2-0) code itself, which hosts all the C++ code for the program.
48 
49 ### PLOT
50 
51 All plotting is done in the `Plot.m` file, which is called upon by `setup.m`.
52 The one parameter in `Plot.m` is SAVEFIG, which simply chooses whether to save the plot in the Figures folder (it will replace existing plots of the same figure!).
53 
54 ______________________________________________
55 
56 ## Help
57 
58 Most of the files are clearly documented at the top of the script. If you need help understanding anything, type
59 
60  help <filename>
61 
62 and there should be an explanation of what the code does/how it works.
63 
64 For general help with a folder, type
65 
66  help <foldername>
67 
68 while inside that folder's workpath for a brief explanation of each file in that folder. It also contains links to more elaborate descriptions.
69 
70 ______________________________________________
71 ## Parameters.ini
72 
73 Within the Execute folder, there should be (1) or more Parameters.ini files, i.e. Parameters0.ini, Parameters.ini, Parameters2.1, ...
74 These files are used to determine how data is achieved and manipulated within the simulation. Looking into the Parameters files themselves will help you understand the specifications of that particular simulation. For example, you can manipulate 'useTau', which chooses the source of tau in your simulation, i.e. from a file, used as a constant, etc.
75 
76 When you run `setup.m` on Figure 2.1 and above (Figure 1 does not require a Parameters.ini file), the parameter file associated with that figure will be copied into Parameters.ini.
77 From there, the .exe will use Parameters.ini to simulate the data.
78 
79 NOTE: Only the Parameters.ini file is intended to change. All other parameter files should never be changed!
80 
81 
82 ## Important Functions (these do not require parameterization)
83 
84 There are only two main functions here:
85 - __`ElectronFlux`.m__: This file calculates the electron flux profile versus L-star for a given Kp, diffusion coefficient, and tau.
86 - __`RadialDiffCoeff`.m__: This file computes the radial diffusion coefficients versus L-star for a given value of Kp, tau and L.
87 
88 All other functions are helper functions used in these codes. The `steady_state`.m file plots the time-independent PSD; the 1D Radial Diffusion folder holds the code needed to reproduce pcolor plots of flux versus L versus time (please see README in that folder).
89 
90 
91 ## Reproduction Tests
92 
93 Please run the following code segments to ensure that the output is in line with expectations.
94 This code should plot Figure 1 for tau = 10 in the paper.
95 
96 
97 ```
98 L = linspace(2,8);
99 Kp = 2;
100 plot(L, 1./RadialDiffCoeff(Kp,L))
101 set(gca,'ylim',[10e-1 10e4],'xlim',[2 8],'yscale','log');
102 ```
103 
104 The code above will reproduce our diffusion coefficients vs. L-star plots (Figure 1, Row 1).
105 
106 ```
107 L = linspace(2,8);
108 Kp = 2;
109 DLL = RadialDiffCoeff(Kp, L);
110 tau = 10;
111 plot(L, steady_state(L, DLL, tau))
112 set(gca,'ylim',[10e-2 10e1],'xlim',[2 8],'yscale','log');
113 ```
114 
115 The code above will reproduce our phase space density vs. L-star plots (Figure 1, Row 2).
116 
117 ```
118 L = linspace(2,8);
119 Kp = 2;
120 tau = 10;
121 plot(L, ElectronFlux(L, Kp, tau))
122 set(gca,'ylim',[10e-1 10e4],'xlim',[2 8],'yscale','log') (Figure 1, Row 3).
123 ```
124 
125 The code above will reproduce our electron flux vs. L-star plots.