Skip to content

Commit

Permalink
Adding files with new template (#51)
Browse files Browse the repository at this point in the history
* Adding files with new template

* adding two new files

* Update docs/arduino/usecase2.md

Co-authored-by: Krishna Kumar <[email protected]>

* Update docs/arduino/usecase_matlab.md

Co-authored-by: Krishna Kumar <[email protected]>

* Small changes to notebooks

* Small change

* small change

* small change

* Adding equations as figures

* and adding the figures to the repository..

* reassigned usecase main file

---------

Co-authored-by: Krishna Kumar <[email protected]>
  • Loading branch information
parduino and kks32 authored Oct 31, 2023
1 parent 3fd0cb4 commit 7bc4001
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 309 deletions.
Binary file added docs/arduino/img/equation-1-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/arduino/img/equation-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/arduino/img/equation-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
280 changes: 37 additions & 243 deletions docs/arduino/usecase.md

Large diffs are not rendered by default.

47 changes: 24 additions & 23 deletions docs/arduino/usecase_matlab.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
# Launching a Matlab script from a Jupyter notebook
# Launching a Matlab script in Jupyter

**Pedro Arduino - University of Washington**
## Launching a Matlab Script from DesignSafe Jupyter Hub using a dedicated Tapis app

This document presents a Jupyter Notebook published in DesignSafe that navigate the process of launching a matlab script from jupyter using a DesignSafe matlab Tapis app. It also exemplifies how to combine matlab and python events in a single notebook. The example makes use of the following DesignSafe resources:
**Pedro Arduino - University of Washington**

[Jupyter notebooks on DS Juypterhub](https://www.designsafe-ci.org/rw/workspace/#!/Jupyter::Analysis){target=_blank}<br/>
*key Words: Matlab, Tapis, Python*

<!--
The accompanying jupyter notebook for this use case can be found in the Community Data folder in [matlabBatch-VM.ipynb](https://jupyter.designsafe-ci.org/user/name/lab/workspaces/auto-J/tree/CommunityData/Jupyter%20Notebooks%20for%20Civil%20Engineering%20Courses/University_of_Washington/MatlabBatch/matlabBatch-VM.ipynb)
-->
## Resources

## Background
### Citation and Licensing
This example makes use of the following DesignSafe resources:

* Please cite [Rathje et al. (2017)](https://doi.org/10.1061/(ASCE)NH.1527-6996.0000246){target=_blank} to acknowledge the use of DesignSafe resources.
[![Open In DesignSafe](https://raw.githubusercontent.com/geoelements/LearnMPM/main/DesignSafe-Badge.svg)](https://jupyter.designsafe-ci.org/hub/user-redirect/lab/tree/CommunityData/Jupyter%20Notebooks%20for%20Civil%20Engineering%20Courses/University_of_Washington/MatlabBatch/matlabBatch-VM.ipynb)

* This software is distributed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html){target=_blank}.
The notebook, and required scripts, are available in the Community Data folder and can be executed without any modification. Users are invited to try this notebook and use any parts of it.


## Description

The notebook utilizes a MATLAB Tapis app (*MATLAB-2022a-VM-1.0.0*) to launch any MATLAB script. For this instance, a simple MATLAB script serves as a example to showcase how to effectively use the app. The matlab script begins by reading acceleration time histories and performing two integrations to produce velocity and displacement time histories. The script then calculates the response spectra for each motion and generates a sequence of plots, while also saving numerical data in ASCII files.
This document presents a Jupyter Notebook published in DesignSafe that navigates the process of launching a matlab script from jupyter using a DesignSafe matlab Tapis app. It also exemplifies how to combine matlab and python events in a single notebook.

The notebook utilizes a MATLAB Tapis app (*MATLAB-2022a-VM-1.0.0*) to launch any MATLAB script. In this example, a simple MATLAB script (*plotMotions.m*) serves as a example to showcase how to effectively use the app. The matlab script begins by reading acceleration time histories and performing two integrations to produce velocity and displacement time histories. The script then calculates the response spectra for each motion saving numerical data in ASCII files.

In a second step, the output files generated by the MATLAB are utilized by Python to generate simple plots. These plots provide an easy-to-understand visualization of the data and enable users to quickly comprehend the results. By combining the capabilities of MATLAB and Python in a single Jupyter notebook, users can develop powerful analysis workflows that can handle complex data sets and generate insightful visualizations.

FInally a simple report is generated using rst2pdf.



A schematic workflow for this example is presented in Fig. 1

<p align="center">
<img src="../img/UC3-Arduino-0.png" alt="Schematic of Matlab workflow" width="500"/>
<img src="./img/UC3-Arduino-0.png" alt="Schematic of Matlab workflow" width="500"/>
</p>
<p align="center"> <b>Fig.1 - Schematic of Matlab workflow</b> </p>


The notebook, and required scripts, are available in the Community Data folder and can be executed without any modification.
Users are invited to try this notebook and use any parts of it.
[matlabBatch-VM.ipynb](https://jupyter.designsafe-ci.org/user/name/lab/workspaces/auto-J/tree/CommunityData/Jupyter%20Notebooks%20for%20Civil%20Engineering%20Courses/University_of_Washington/MatlabBatch/matlabBatch-VM.ipynb)

## Implementation

The notebook can be broken down into three main components:

Expand Down Expand Up @@ -128,10 +125,9 @@ job_description["notifications"] = [
]
```


#### Run Matlab script

Submitting a job using DesignSafe HPC resources requires the use of agave job.submit(); and passing the job_description array as argument. Checking the status of a job can be done using jobs.getStatus(). The python code shown below exemplifies these commands. In the notebook a simple python function is included in *DS_GenFunctions.py* that encapsulates the GetStatus process. When submitting a job, agave copies all the files present in the input folder to a temporary location that is used during execution. After completion agave copies all the results to an archived folder.
Submitting a job using DesignSafe HPC resources requires the use of agave/tapis job.submit(); and passing the job_description array as argument. Checking the status of a job can be done using jobs.getStatus(). The python code shown below exemplifies these commands. In the notebook a simple python function is included in *DS_GenFunctions.py* that encapsulates the GetStatus process. When submitting a job, agave/tapis copies all the files present in the input folder to a temporary location that is used during execution. After completion agave/tapis copies all the results to an archived folder.

```python
import time
Expand All @@ -149,7 +145,7 @@ while status != "FINISHED":

### Postprocess Results using Python

With JupyterHub, post-processing can be efficiently carried out using Python, R, or Julia through DesignSafe. Independent of scripting language, postprocessing requires identification of the location of the archived files. This is done interrogating a particular agave job and evaluating the correct folder location. The python code lines shown below exemplifly the steps required for this purpose.
With JupyterHub, post-processing can be efficiently carried out using Python, R, or Julia through DesignSafe. Independent of scripting language, postprocessing requires identification of the location of the archived files. This is done interrogating a particular agave/tapis job and evaluating the correct folder location. The python code lines shown below exemplifly the steps required for this purpose.


#### Identify job, archived location and user
Expand Down Expand Up @@ -213,7 +209,7 @@ for ii in range(3):
```

<p align="center">
<img src="../img/UC3-Arduino-1.png" alt="Time histories" width="400"/>
<img src="./img/UC3-Arduino-1.png" alt="Time histories" width="400"/>
</p>
<p align="center"> <b>Fig.2 - Displacement, velocity and acceleration time history for selected motion</b> </p>

Expand Down Expand Up @@ -245,7 +241,7 @@ axs2[0].grid(True)
```

<p align="center">
<img src="../img/UC3-Arduino-2.png" alt="Response spectra" width="400"/>
<img src="./img/UC3-Arduino-2.png" alt="Response spectra" width="400"/>
</p>
<p align="center"> <b>Fig.3 - Response spectra</b> </p>

Expand Down Expand Up @@ -285,5 +281,10 @@ class PDF(object):
return r'\includegraphics[width=1.0\textwidth]{{{0}}}'.format(self.pdf)
```

## Citation and Licensing

* Please cite [Rathje et al. (2017)](https://doi.org/10.1061/(ASCE)NH.1527-6996.0000246){target=_blank} to acknowledge the use of DesignSafe resources.

* This software is distributed under the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html){target=_blank}.


Loading

0 comments on commit 7bc4001

Please sign in to comment.