Skip to content

Commit

Permalink
added livescripts to matlab examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhroom committed Jan 29, 2025
1 parent a350862 commit c0c7cb0
Show file tree
Hide file tree
Showing 17 changed files with 1,494 additions and 311 deletions.
8 changes: 8 additions & 0 deletions setup_livescripts.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export('./API/examples/normalReflectivity/standardLayers/standardLayersDSPCSheet.mlx', './source/matlab_examples/standardLayersDSPCSheet.html');
export('./API/examples/normalReflectivity/customLayers/customLayersDSPCSheet.mlx', './source/matlab_examples/customLayersDSPCSheet.html');
export('./API/examples/normalReflectivity/customXY/customXYDSPCSheet.mlx', './source/matlab_examples/customXYDSPCSheet.html');
export('./API/examples/domains/standardLayers/domainsStandardLayersSheet.mlx', './source/matlab_examples/domainsStandardLayersSheet.html');
export('./API/examples/domains/customLayers/domainsCustomLayersSheet.mlx', './source/matlab_examples/domainsCustomLayersSheet.html');
export('./API/examples/domains/customXY/domainsCustomXYSheet.mlx', './source/matlab_examples/domainsCustomXYSheet.html');
export('./API/examples/miscellaneous/convertRascal1Project/convertRascal.mlx', './source/matlab_examples/convertRascal.html');
export('./API/examples/miscellaneous/alternativeLanguages/customModelLanguagesSheet.mlx', './source/matlab_examples/customModelLanguagesSheet.html');
2 changes: 2 additions & 0 deletions setup_tutorials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ cp -r python-RAT/RATapi/examples/absorption/* source/python_examples/notebooks/
cp -r python-RAT/RATapi/examples/data source/python_examples/

rm -rf python-RAT

cat setup_livescripts.m | matlab -nodisplay -nosplash
70 changes: 22 additions & 48 deletions source/matlab_examples/DSPC_custom_layers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,25 @@ In addition, the datasets for this example, have a resolution (per point) in the

This example can be run as a script or interactively using the instructions below.

.. tab-set::
:sync-group: code

.. tab-item:: Matlab
:sync: Matlab

.. note:: The custom model used is a MATLAB model - **examples/normalReflectivity/customLayers/customBilayerDSPC.m**.

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'customLayers'));
customLayersDSPCScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'customLayers'));
edit customLayersDSPCSheet.mlx
.. tab-item:: Python
:sync: Python

.. note:: The custom model used is a Python model - **RATapi.examples.normal_reflectivity.custom_bilayer_DSPC.py**.

**Run Script**:

.. code-block:: console
python RATapi.examples.normal_reflectivity.DSPC_custom_layers.py
**Run as Function**:

.. code-block:: Python
import RATapi as RAT
problem, results = RAT.examples.normal_reflectivity.DSPC_custom_layers()
**Run Interactively**:

.. code-block:: console
jupyter notebook RATapi.examples.normal_reflectivity.DSPC_custom_layers.ipynb

.. note:: The custom model used is a MATLAB model - **examples/normalReflectivity/customLayers/customBilayerDSPC.m**.

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'customLayers'));
customLayersDSPCScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'customLayers'));
edit customLayersDSPCSheet.mlx
.. raw:: html
:file: customLayersDSPCSheet.html
63 changes: 19 additions & 44 deletions source/matlab_examples/DSPC_standard_layers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,22 @@ The model is set up in the script, we set Gaussian priors on some of the paramet

This example can be run as a script or interactively using the instructions below.

.. tab-set::
:sync-group: code

.. tab-item:: Matlab
:sync: Matlab

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'standardLayers'));
standardLayersDSPCScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'standardLayers'));
edit standardLayersDSPCSheet.mlx
.. tab-item:: Python
:sync: Python

**Run Script**:

.. code-block:: console
python RATapi.examples.normal_reflectivity.DSPC_standard_layers.py
**Run as Function**:

.. code-block:: Python
import RATapi as RAT
problem, results = RAT.examples.normal_reflectivity.DSPC_standard_layers()
**Run Interactively**:

.. code-block:: console
jupyter notebook RATapi.examples.normal_reflectivity.DSPC_standard_layers.ipynb

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'standardLayers'));
standardLayersDSPCScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'normalReflectivity', 'standardLayers'));
edit standardLayersDSPCSheet.mlx
.. raw:: html
:file: standardLayersDSPCSheet.html
99 changes: 99 additions & 0 deletions source/matlab_examples/convertRascal.html

Large diffs are not rendered by default.

53 changes: 12 additions & 41 deletions source/matlab_examples/convert_r1_project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,15 @@ function **Model_IIb.m** which in the example directory is required to run the c

This example can be run using the instructions below.

.. tab-set::
:sync-group: code

.. tab-item:: Matlab
:sync: Matlab

.. note:: The custom model used is a MATLAB model - **examples/miscellaneous/convertRascal1Project/Model_IIb.m**.

**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'convertRascal1Project'));
edit convertRascal.mlx
.. tab-item:: Python
:sync: Python

.. note:: The custom model used is a MATLAB model - **RATapi.examples.convert_rascal_project.Model_IIb.m**.
A python version is provided for the jupyter notebook - **RATapi.examples.convert_rascal_project.Model_IIb.py**

**Run Script**:

.. code-block:: console
python RATapi.examples.convert_rascal_project.convert_rascal.py
**Run as Function**:

.. code-block:: Python
import RATapi as RAT
problem, results = RAT.examples.convert_rascal_project.convert_rascal()
**Run Interactively**:

.. code-block:: console
jupyter notebook RATapi.examples.convert_rascal_project.convert_rascal.ipynb
.. note:: The custom model used is a MATLAB model - **examples/miscellaneous/convertRascal1Project/Model_IIb.m**.

**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'convertRascal1Project'));
edit convertRascal.mlx
.. raw:: html
:file: convertRascal.html
201 changes: 201 additions & 0 deletions source/matlab_examples/customLayersDSPCSheet.html

Large diffs are not rendered by default.

204 changes: 204 additions & 0 deletions source/matlab_examples/customModelLanguagesSheet.html

Large diffs are not rendered by default.

299 changes: 299 additions & 0 deletions source/matlab_examples/customXYDSPCSheet.html

Large diffs are not rendered by default.

70 changes: 25 additions & 45 deletions source/matlab_examples/custom_model_languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,30 @@ The provided C++ function needs to be compiled into a dynamic library using inst


This example can be run using the instructions below.


.. tab-set::
:sync-group: code

.. tab-item:: Matlab
:sync: Matlab

.. note:: The custom models used are -
**examples/miscellaneous/languages/alloyDomains.m**,
**examples/miscellaneous/languages/alloyDomains.m**,
**examples/miscellaneous/languages/alloyDomains.m**.

.. warning:: For Python custom functions, you will need to setup the python environment for MATLAB, see `Setup MATLAB to use Python <https://uk.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html>`_

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'alternativeLanguages'));
customModelLanguagesScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'alternativeLanguages'));
edit customModelLanguagesSheet.mlx
.. tab-item:: Python
:sync: Python

.. note:: The custom models used are -
**RATapi.examples.languages.custom_bilayer.cpp**,
**RATapi.examples.languages.custom_bilayer.py**,
**RATapi.examples.languages.custom_bilayer.m**.

.. warning:: For MATLAB custom functions, ensure MATLAB and matlabengine are installed :ref:`install`.

**Run Script**:

.. code-block:: console
python RATapi.examples.languages.run_custom_file_languages.py
.. note:: The custom models used are -
**examples/miscellaneous/languages/alloyDomains.m**,
**examples/miscellaneous/languages/alloyDomains.m**,
**examples/miscellaneous/languages/alloyDomains.m**.

.. warning:: For Python custom functions, you will need to setup the python environment for MATLAB, see `Setup MATLAB to use Python <https://uk.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html>`_

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'alternativeLanguages'));
customModelLanguagesScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'miscellaneous', 'alternativeLanguages'));
edit customModelLanguagesSheet.mlx
.. raw:: html
:file: customModelLanguagesSheet.html
94 changes: 94 additions & 0 deletions source/matlab_examples/domainsCustomLayersSheet.html

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions source/matlab_examples/domainsCustomXYSheet.html

Large diffs are not rendered by default.

127 changes: 127 additions & 0 deletions source/matlab_examples/domainsStandardLayersSheet.html

Large diffs are not rendered by default.

69 changes: 21 additions & 48 deletions source/matlab_examples/domains_custom_XY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,24 @@ This parameter tells the function which is the current domain, so the appropriat

This example can be run as a script or interactively using the instructions below.

.. tab-set::
:sync-group: code

.. tab-item:: Matlab
:sync: Matlab

.. note:: The custom model used is a MATLAB model - **examples/domains/customXY/domainsXY.m**.

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customXY'));
domainsCustomXYScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customXY'));
edit domainsCustomXYSheet.mlx
.. tab-item:: Python
:sync: Python

.. note:: The custom model used is a Python model - **RATapi.examples.domains.domains_XY_model.py**.

**Run Script**:

.. code-block:: console
python RATapi.examples.domains.domains_custom_XY.py
**Run as Function**:

.. code-block:: Python
import RATapi as RAT
problem, results = RAT.examples.domains.domains_custom_XY()
**Run Interactively**:

.. code-block:: console
jupyter notebook RATapi.examples.domains.domains_custom_XY.ipynb

.. note:: The custom model used is a MATLAB model - **examples/domains/customXY/domainsXY.m**.

**Run Script**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customXY'));
domainsCustomXYScript
**Run Interactively**:

.. code-block:: Matlab
root = getappdata(0, 'root');
cd(fullfile(root, 'examples', 'domains', 'customXY'));
edit domainsCustomXYSheet.mlx
.. raw:: html
:file: domainsCustomXYSheet.html
Loading

0 comments on commit c0c7cb0

Please sign in to comment.