diff --git a/README.md b/README.md index ae07b5a0..a6ff64c7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ folder while the build will be placed in a build folder. The build requires a py in the requirements.txt. You need MATLAB version and python version or RAT software installed in your system. ```bash - conda create -n RAT python=3.9 + conda create -n RAT python=3.10 conda activate RAT pip install -r requirements.txt ``` diff --git a/source/advanced/customLanguages.rst b/source/advanced/customLanguages.rst index dc1f3fbc..7be269a0 100644 --- a/source/advanced/customLanguages.rst +++ b/source/advanced/customLanguages.rst @@ -19,6 +19,9 @@ Python Custom Models .. note:: Before you use Python from your MATLAB session, please ensure that Python is `configured correctly on your system. `_ +.. warning:: + The value of contrast and domain number will always start from 1 (not 0) so be careful if contrast/domain number is used for array indexing. + You will need to subtract one from contrast e.g :code:`bulk_in[contrast - 1]` to avoid code failure. Custom models in Python and MATLAB are very similar in structure as shown below: @@ -156,13 +159,13 @@ Custom models in Python and MATLAB are very similar in structure as shown below: # Manually deal with hydration for layers in # this example. - oxSLD = (oxide_hydration * bulk_out[contrast]) + ((1 - oxide_hydration) * oxide_SLD) - headSLD = (headHydration * bulk_out[contrast]) + ((1 - headHydration) * SLDhead) - tailSLD = (bilayerHydration * bulk_out[contrast]) + ((1 - bilayerHydration) * SLDtail) + oxSLD = (oxide_hydration * bulk_out[contrast-1]) + ((1 - oxide_hydration) * oxide_SLD) + headSLD = (headHydration * bulk_out[contrast-1]) + ((1 - headHydration) * SLDhead) + tailSLD = (bilayerHydration * bulk_out[contrast-1]) + ((1 - bilayerHydration) * SLDtail) # Make the layers oxide = [oxide_thick, oxSLD, sub_rough] - water = [waterThick, bulk_out[contrast], bilayerRough] + water = [waterThick, bulk_out[contrast-1], bilayerRough] head = [headThick, headSLD, bilayerRough] tail = [tailThick, tailSLD, bilayerRough] @@ -259,9 +262,9 @@ Following on from our custom bilayer examples, the equivalent C++ custom model s // Manually deal with hydration for layers in // this example. - double oxSLD = (oxideHydration * bulkOut[contrast]) + ((1 - oxideHydration) * oxideSLD); - double headSLD = (headHydration * bulkOut[contrast]) + ((1 - headHydration) * SLDhead); - double tailSLD = (bilayerHydration * bulkOut[contrast]) + ((1 - bilayerHydration) * SLDtail); + double oxSLD = (oxideHydration * bulkOut[contrast-1]) + ((1 - oxideHydration) * oxideSLD); + double headSLD = (headHydration * bulkOut[contrast-1]) + ((1 - headHydration) * SLDhead); + double tailSLD = (bilayerHydration * bulkOut[contrast-1]) + ((1 - bilayerHydration) * SLDtail); // Make the layers // oxide... @@ -271,7 +274,7 @@ Following on from our custom bilayer examples, the equivalent C++ custom model s // Water... output.push_back(waterThick); - output.push_back(bulkOut[contrast]); + output.push_back(bulkOut[contrast-1]); output.push_back(bilayerRough); // Heads... diff --git a/source/api.rst b/source/api.rst index ed54785c..d1b11686 100644 --- a/source/api.rst +++ b/source/api.rst @@ -376,7 +376,7 @@ Controls Class ============== ControlsClass is all about control. It is necessary in determine the way RAT works. It deals with how the user interacts with the software. From type of parallelization -to whether the users wants to calculate SLD during fit and even how many iteration an algorithm should do ..etc. +to how many iterations an algorithm should do etc. There are 5 different `controlsClass.procedures` that can be used with RAT. They are: @@ -397,9 +397,9 @@ if yes, what to parallelize on. (Points or Contrasts or all) :caption: Sample usage of controlsClass. controls = controlsClass(); - controls.calcSldDuringFit = false; - controls.nsimu = 7000; - controls.repeats = 3; + controls.procedure = 'dream'; + controls.nSamples = 6000; + controls.nChains = 10; controls.parallel = 'contrasts'; .. code-block:: MATLAB @@ -429,7 +429,7 @@ After the user has defined the projectClass and controlsClass, the user can run [problem,results] = RAT(problem,controls); -When the RAT function is called, the classes are passed into internal functions like `RatParseClassToStructs_new` which takes the classes and breaks them down into cells, +When the RAT function is called, the classes are passed into internal functions like `parseClassToStructs` which takes the classes and breaks them down into cells, limits,prior and more importantly converts the project class to struct. Then, the `RATMain` function redirects the control flow based on what procedure is selected in controlsClass. One of the redirecting functions will call the reflectivityCalculation @@ -437,4 +437,4 @@ which starts the reflectivity calculation. Some interesting data type changes are needed because of how things work with coder. Coder wont accept variable sized cell arrays contains variable sized arrays (strings for eg) -in a field of a struct. So, look at `RatParseClassToStructs_new` function to understand how the data is converted. +in a field of a struct. So, look at `parseClassToStructs` function to understand how the data is converted. diff --git a/source/matlab_examples.pdf b/source/matlab_examples.pdf deleted file mode 100644 index 086835e9..00000000 Binary files a/source/matlab_examples.pdf and /dev/null differ diff --git a/source/tutorial/controls.rst b/source/tutorial/controls.rst index 8679aa0a..75cda977 100644 --- a/source/tutorial/controls.rst +++ b/source/tutorial/controls.rst @@ -106,11 +106,6 @@ How the calculation should be :ref:`parallelised`. Currently th Which option is more efficient will depend on the number of contrasts and the size of your data. -``calcSldDuringFit`` -^^^^^^^^^^^^^^^^^^^^ -A boolean (true or false) value which determines whether SLD will be calculated during the fit -(for :ref:`live plotting` etc.) - ``display`` ^^^^^^^^^^^ How much RAT should print to the terminal. The current options are: diff --git a/source/tutorial/customModels.rst b/source/tutorial/customModels.rst index 156a9777..27a481c8 100644 --- a/source/tutorial/customModels.rst +++ b/source/tutorial/customModels.rst @@ -341,13 +341,13 @@ At this point it is useful to look at our custom function and then go through it # Manually deal with hydration for layers in # this example. - oxSLD = (oxide_hydration * bulk_out[contrast]) + ((1 - oxide_hydration) * oxide_SLD) - headSLD = (headHydration * bulk_out[contrast]) + ((1 - headHydration) * SLDhead) - tailSLD = (bilayerHydration * bulk_out[contrast]) + ((1 - bilayerHydration) * SLDtail) + oxSLD = (oxide_hydration * bulk_out[contrast-1]) + ((1 - oxide_hydration) * oxide_SLD) + headSLD = (headHydration * bulk_out[contrast-1]) + ((1 - headHydration) * SLDhead) + tailSLD = (bilayerHydration * bulk_out[contrast-1]) + ((1 - bilayerHydration) * SLDtail) # Make the layers oxide = [oxide_thick, oxSLD, sub_rough] - water = [waterThick, bulk_out[contrast], bilayerRough] + water = [waterThick, bulk_out[contrast-1], bilayerRough] head = [headThick, headSLD, bilayerRough] tail = [tailThick, tailSLD, bilayerRough] @@ -408,7 +408,7 @@ Therefore, the effective SLD of the oxide layer at a particular contrast is give .. code-block:: Python oxide_SLD = 3.41e-6 - oxSLD = (oxide_hydration * bulk_out[contrast]) + ((1 - oxide_hydration) * oxide_SLD) + oxSLD = (oxide_hydration * bulk_out[contrast-1]) + ((1 - oxide_hydration) * oxide_SLD) To work out the thickness of the lipid layers, we use literature values for the head and tails volumes, and divide these by the APM (the fourth input parameter in ``params``): @@ -503,8 +503,8 @@ We also do the coverage correction as we did for the Oxide: .. code-block:: Python - headSLD = (headHydration * bulk_out[contrast]) + ((1 - headHydration) * SLDhead) - tailSLD = (bilayerHydration * bulk_out[contrast]) + ((1 - bilayerHydration) * SLDtail) + headSLD = (headHydration * bulk_out[contrast-1]) + ((1 - headHydration) * SLDhead) + tailSLD = (bilayerHydration * bulk_out[contrast-1]) + ((1 - bilayerHydration) * SLDtail) This gives us all the parameters we need to define our layers. In other words, we have a thickness, SLD and roughness for each layer then put these together to make our stack: @@ -524,7 +524,7 @@ In other words, we have a thickness, SLD and roughness for each layer then put t # Make the layers oxide = [oxide_thick, oxSLD, sub_rough] - water = [waterThick, bulk_out[contrast], bilayerRough] + water = [waterThick, bulk_out[contrast-1], bilayerRough] head = [headThick, headSLD, bilayerRough] tail = [tailThick, tailSLD, bilayerRough]