Python Lab Tutorials: Lab 1
- Write a function in Python whose inputs are another function
and two values
and
. If
, the output of the function should be the vector
, otherwise, the function should return the message: “Please ensure that
is less than
“. Show that this function works properly for different cases. - Use a “
for” loop to create a function whose input is a vector of numbers. The function should check for the first occurrence of a number whose absolute value is less than 0.0005. The function should output the index number and that particular value. For example, if the input is the vector
, then the output should be
. If none of the absolute values of the components of the vector is less than 0.0005, the function should output: “N/A”. Repeat the problem using a “while” loop. - The von Mises stress
(or sometimes called equivalent stress) gives a positive measure of the state of stress given by the symmetric stress matrix:![Rendered by QuickLaTeX.com \[\sigma=\left(\begin{matrix}\sigma_{11} & \sigma_{12} & \sigma_{13} \\ \sigma_{12} & \sigma_{22} & \sigma_{23} \\ \sigma_{13} & \sigma_{23} & \sigma_{33} \end{matrix}\right)\]](https://engcourses-uofa.ca/wp-content/ql-cache/quicklatex.com-8dd9d6cce3dd4069fd4a2354200278d0_l3.png)
is defined as:![Rendered by QuickLaTeX.com \[\sigma_{vM}=\sqrt{\frac{(\sigma_{11}-\sigma_{22})^2+(\sigma_{22}-\sigma_{33})^2+(\sigma_{11}-\sigma_{33})^2+6(\sigma_{12}^2+\sigma_{13}^2+\sigma_{23}^2)}{2}}\]](https://engcourses-uofa.ca/wp-content/ql-cache/quicklatex.com-d402936a8e545ca18bb762404f458cbd_l3.png)
Create a function in Python whose argument is a
matrix and whose output is the von Mises stress. Use this function to show that the equivalent stress is the same for the following stress matrices (units of MPa):![Rendered by QuickLaTeX.com \[\sigma_a=\left(\begin{matrix}2&2&0\\2&5&0\\0&0&-5\end{matrix}\right)\qquad \sigma_b=\left(\begin{matrix}1&0&0\\0&-5&0\\0&0&6\end{matrix}\right)\]](https://engcourses-uofa.ca/wp-content/ql-cache/quicklatex.com-7efc1de42f8faf28dbe0280ea9c4b4c0_l3.png)
