summaryrefslogtreecommitdiff
path: root/book
diff options
context:
space:
mode:
Diffstat (limited to 'book')
-rw-r--r--book/computingME.pdfbin3597869 -> 3782618 bytes
-rw-r--r--book/computingME.tex2
-rw-r--r--book/module0/module0.tex2
-rw-r--r--book/module1/array.tex19
-rw-r--r--book/module1/jupyter_lab_notebook.tex131
-rw-r--r--book/module1/spyder_getting_started.tex8
-rw-r--r--book/module2/problem_solving_strategies.tex145
7 files changed, 121 insertions, 186 deletions
diff --git a/book/computingME.pdf b/book/computingME.pdf
index fcfddc1..145ae15 100644
--- a/book/computingME.pdf
+++ b/book/computingME.pdf
Binary files differ
diff --git a/book/computingME.tex b/book/computingME.tex
index 31cba87..2267856 100644
--- a/book/computingME.tex
+++ b/book/computingME.tex
@@ -5,7 +5,7 @@
\input{preamble.inc}
\title{MECH 305 - Computing for Mechanical: Tutorials}
\author{Christian Kolset}
-\date{July 2013}
+\date{April 2025}
\titlehead{Tutorials for MECH 305 - Computing for Mechanical Engineers}
\publishers{Walter Scott Jr. College of Engineering\\Colorado State University}
diff --git a/book/module0/module0.tex b/book/module0/module0.tex
index 9b3c8dc..6f2a4ad 100644
--- a/book/module0/module0.tex
+++ b/book/module0/module0.tex
@@ -1,3 +1,3 @@
\chapter{Getting Started}
\input{module0/intro_to_programming}
-\input{module0/intro_to_anaconda}
+\input{module0/installing_anaconda}
diff --git a/book/module1/array.tex b/book/module1/array.tex
index c79c6c0..9482065 100644
--- a/book/module1/array.tex
+++ b/book/module1/array.tex
@@ -35,13 +35,7 @@ the value of the element as a property. In other words, if we were to
analyze the stress concentration of an aluminum block, the property
would be stress.
-\begin{itemize}
-\tightlist
-\item
- From
- \href{https://numpy.org/doc/2.2/user/absolute_beginners.html}{Numpy
- documentation} \includegraphics{figures/multi-dimensional-array.gif}
-\end{itemize}
+\includegraphics{figures/multi-dimensional-array.png}
If the load on this block changes over time, then we may want to add a
4th dimension i.e.~additional sets of 3-D arrays for each time
@@ -197,7 +191,7 @@ recorded as a function of time.
\begin{Highlighting}[]
\NormalTok{thrust\_lbf }\OperatorTok{=}\NormalTok{ np.array(}\FloatTok{0.603355}\NormalTok{, }\FloatTok{2.019083}\NormalTok{, }\FloatTok{2.808092}\NormalTok{, }\FloatTok{4.054973}\NormalTok{, }\FloatTok{1.136618}\NormalTok{, }\FloatTok{0.943668}\NormalTok{)}
-\OperatorTok{\textgreater{}\textgreater{}\textgreater{}}\NormalTok{ thrust\_lbs[}\DecValTok{3}\NormalTok{]}
+\BuiltInTok{print}\NormalTok{(thrust\_lbs[}\DecValTok{3}\NormalTok{])}
\end{Highlighting}
\end{Shaded}
@@ -211,10 +205,7 @@ product - \texttt{np.matmul()} for matrix multiplication -
\#\#\#\#\# Statistics - \texttt{np.mean()}, \texttt{np.median()},
\texttt{np.std()}, \texttt{np.var()} - \texttt{np.min()},
\texttt{np.max()}, \texttt{np.argmin()}, \texttt{np.argmax()} -
-Summation along axes: \texttt{np.sum(arr,\ axis=0)} \#\#\#\#\# Combining
-arrays - Concatenation: \texttt{np.concatenate((arr1,\ arr2),\ axis=0)}
-- Stacking: \texttt{np.vstack()}, \texttt{np.hstack()} - Splitting:
-\texttt{np.split()}
+Summation along axes: \texttt{np.sum(arr,\ axis=0)}
\subsection{Exercise}\label{exercise}
@@ -256,9 +247,9 @@ point must be zero.
\subparagraph{System of Equations:}\label{system-of-equations}
-\{RA+RB−10−15−20=05(10)+10(15)+15(20)−20RB=020RA−5(10)−10(15)−15(20)=0
-
+\[
\begin{cases} R_A + R_B - 10 - 15 - 20 = 0 \\ 5(10) + 10(15) + 15(20) - 20 R_B = 0 \\ 20 R_A - 5(10) - 10(15) - 15(20) = 0 \end{cases}
+\]
\subsubsection{Solution}\label{solution}
diff --git a/book/module1/jupyter_lab_notebook.tex b/book/module1/jupyter_lab_notebook.tex
index 5c06f5d..c08fd74 100644
--- a/book/module1/jupyter_lab_notebook.tex
+++ b/book/module1/jupyter_lab_notebook.tex
@@ -21,32 +21,6 @@ Terminal: \texttt{conda\ install\ conda-forge::jupyterlab}
\subsection{Notebook Basics}\label{notebook-basics}
-\begin{itemize}
-\tightlist
-\item
- Creating a new notebook (\texttt{.ipynb})
-\item
- Types of cells:
-
- \begin{itemize}
- \tightlist
- \item
- Code
- \item
- Markdown
- \item
- Raw
- \end{itemize}
-\item
- Running a cell: \texttt{Shift\ +\ Enter}
-\item
- Adding/removing cells
-\item
- Restarting the kernel
-\item
- Saving and auto-checkpoints
-\end{itemize}
-
Jupyter Notebooks are files which allows you to combine \emph{Code} and
\emph{Markdown} cells in one single document. The code cells, allow you
to interactively run python code and print and plot data in your
@@ -100,7 +74,8 @@ affects the results of any cells that use that variable afterward ---
but not any previously run results unless you rerun them too. Variables
and imports persist in memory between cells, but only based on the
current session state --- if you restart the kernel, you lose all
-previous definitions unless you re-run the necessary cells.
+previous definitions unless you re-run the necessary cells. Therefore,
+let's press the \texttt{Restart\ the\ kernel} button on the top window.3
Because of this, it's best practice to; Run cells in order, restart the
kernel and run all cells
@@ -109,85 +84,57 @@ everything works cleanly and predictably and lastly, initialize
important variables or imports in early cells, so they are always
defined before they are needed.
-\subsection{Writing and Running Code}\label{writing-and-running-code}
+\subsection{Making your document look good with
+Markdown}\label{making-your-document-look-good-with-markdown}
-\begin{itemize}
-\tightlist
-\item
- Python syntax: - \texttt{print("Hello,\ world!")} - Variables and
- functions - Loops and conditionals
-\item
- Importing libraries: - \texttt{import\ numpy\ as\ np} -
- \texttt{import\ pandas\ as\ pd} -
- \texttt{import\ matplotlib.pyplot\ as\ plt}
-\end{itemize}
+Creating titles or headers is done with the hash symbol. The number of
+hashes determines whether it's a sub-title \texttt{\#}, \texttt{\#\#},
+\texttt{\#\#\#}
-\subsection{Using Markdown}\label{using-markdown}
+\subsubsection{Lists}\label{lists}
+
+There are two types of list in - Bullet lists: \texttt{-\ item} -
+Numbered lists: \texttt{1.\ item} \#\#\# Style - Emphasis:
+\emph{italic}, \textbf{bold}, \texttt{monospace} \#\#\# Mathematical
+Equation Markdown supports LaTeX format equations. Inline equation is
+opened and closed with a single \texttt{\$}. For a block math a double
+\texttt{\$\$} is used instead of single.
\begin{itemize}
\tightlist
\item
- Headers: \texttt{\#}, \texttt{\#\#}, \texttt{\#\#\#}
-\item
- Bullet lists: \texttt{-\ item}
-\item
- Numbered lists: \texttt{1.\ item}
-\item
- Emphasis: \emph{italic}, \textbf{bold}, \texttt{monospace}
+ Inline: This equation is inline \texttt{\$E\ =\ mc\^{}2\$} in with the
+ markdown text.
\item
- LaTeX equations:
-
- \begin{itemize}
- \tightlist
- \item
- Inline: \texttt{\$E\ =\ mc\^{}2\$}
- \item
- Block:
- \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$}
- \end{itemize}
-\item
- Embedding links and images
+ Block: Whilst this is a block:
+ \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$}
+ \#\#\# Links and images You can insert links to a different local file
+ or online urls like this: {[}Link{]}(file.md). I insert an image it's
+ the same however start with an exclamation mark \texttt{!} like this:
+ !{[}Image Caption{]}(picture.png)
\end{itemize}
-\subsection{Interactive Widgets
-(optional)}\label{interactive-widgets-optional}
-
-Install \texttt{ipywidgets} from your package manager
-
-\begin{Shaded}
-\begin{Highlighting}[]
-\ImportTok{import}\NormalTok{ ipywidgets }\ImportTok{as}\NormalTok{ widgets}
-\NormalTok{widgets.IntSlider()}
-\end{Highlighting}
-\end{Shaded}
-
-Example using interact:
+\subsection{Exporting and Sharing}\label{exporting-and-sharing}
-\begin{Shaded}
-\begin{Highlighting}[]
-\ImportTok{from}\NormalTok{ ipywidgets }\ImportTok{import}\NormalTok{ interact}
-\NormalTok{interact(}\KeywordTok{lambda}\NormalTok{ x: x}\OperatorTok{**}\DecValTok{2}\NormalTok{, x}\OperatorTok{=}\DecValTok{5}\NormalTok{)}
-\end{Highlighting}
-\end{Shaded}
+To export your notebook go to
-\subsection{Exporting and Sharing}\label{exporting-and-sharing}
+\texttt{File} \textgreater{} \texttt{Download\ As}
-By default, jupyter auto-saves your notebooks as you work.
+You can then select these options.
\begin{itemize}
\tightlist
\item
- File \textgreater{} Download As:
-
- \begin{itemize}
- \tightlist
- \item
- Notebook (\texttt{.ipynb})
- \item
- HTML
- \item
- PDF (requires LaTeX)
- \item
- Markdown
- \end{itemize}
+ Notebook (\texttt{.ipynb})
+\item
+ HTML
+\item
+ PDF (requires LaTeX)
+\item
+ Markdown
\end{itemize}
+
+For homework assignments, download an HTML version of your document,
+then from your browser, save or print as a PDF. Alternatively, you can
+install the LaTeX typesetting system and export your document directly
+as PDF from jupyter.
diff --git a/book/module1/spyder_getting_started.tex b/book/module1/spyder_getting_started.tex
index 70a3d41..3133b15 100644
--- a/book/module1/spyder_getting_started.tex
+++ b/book/module1/spyder_getting_started.tex
@@ -86,9 +86,11 @@ computations, assign and modify variables.
\item
Display of Matplotlib graphics in Spyder's
\href{https://docs.spyder-ide.org/5/panes/plots.html}{Plots} pane, if
- the Inline backend is selected under Preferences ‣ IPython console ‣
- Graphics ‣ Graphics backend, and inline in the console if Mute inline
- plotting is unchecked under the Plots pane's options menu.
+ the Inline backend is selected under \texttt{Preferences}
+ \textgreater{} \texttt{IPython\ console} \textgreater{}
+ \texttt{Graphics} \textgreater{} \texttt{Graphics\ backend}, and
+ inline in the console if Mute inline plotting is unchecked under the
+ Plots pane's options menu.
\end{itemize}
\subsubsection{Variable Explorer}\label{variable-explorer}
diff --git a/book/module2/problem_solving_strategies.tex b/book/module2/problem_solving_strategies.tex
index 4b908f8..2f7a360 100644
--- a/book/module2/problem_solving_strategies.tex
+++ b/book/module2/problem_solving_strategies.tex
@@ -1,44 +1,49 @@
\section{Algorithmic thinking}\label{algorithmic-thinking}
-\subsection{Learning Objectives}\label{learning-objectives}
-
-By the end of this lesson, students will be able to:
-
-\begin{itemize}
-\tightlist
-\item
- Apply algorithmic thinking to solve engineering problems using
- computational tools.
-\item
- Translate engineering problems into structured programming logic.
-\item
- Use software tools to implement, test, and refine engineering
- solutions.
-\end{itemize}
+In engineering, solving a problem begins long before we start coding or
+building models. Like any other engineering challenge, computational
+problems must first be clearly framed and understood. In this section,
+you will learn to \textbf{apply algorithmic thinking} to systematically
+approach engineering problems, \textbf{translate real-world situations
+into structured programming logic}, and \textbf{use computational tools
+to implement, test, and refine solutions}.
+
+Before diving into code, it's crucial to define the problem carefully,
+frame the problem so that logically so that a computer can understand
+then execute so that
\subsection{Define the Problem}\label{define-the-problem}
-Like many other classes we need to frame the problem before working it.
-So before jumping straight into coding or building models, clearly
-define the engineering problem.
+As any other engineering problem, we need to frame it before we can
+start working on it. So before jumping straight into coding or building
+models, clearly define the engineering problem.
-\begin{itemize}
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
- \textbf{List knowns and unknowns.} What inputs are given? What outputs
- are required?
+ List your givens, this includes any constants or equations. What
+ inputs do we know?
\item
- \textbf{Establish system constraints and assumptions.} Identify
- physical laws, design requirements, and performance limits.
+ Find: List what you're trying to solve for. What outputs do we need to
+ find?
\item
- \textbf{Clarify computational objectives.} What are you trying to
- calculate, simulate, or optimize?
-\end{itemize}
+ Establish the assumptions based on your engineering knowledge that you
+ deem to be appropriate to use for the problem. This determines what
+ mathematical models we can apply to the problem (i.e.~equations or
+ formulas).
+\item
+ Solution: Show the works of the problem, this will include any code
+ used together with documentation or any explanations of the code.
+\item
+ Comment: reflect and comment on your findings.
+\end{enumerate}
\subsection{Think Algorithmically}\label{think-algorithmically}
-Since we are going to use computers to calculate our solution we first
+Since we are going to use computers to compute our calculate we first
need to break the problem into logical steps that a computer can follow.
+This can be done with tools such as flowchart or psuedo-code.
\begin{itemize}
\tightlist
@@ -49,79 +54,69 @@ need to break the problem into logical steps that a computer can follow.
\textbf{Break the problem into sub-tasks.} Identify steps such as data
input, logic processing and output.
\item
- \textbf{Outline the algorithm.} Write pseudocode or flowcharts that
+ \textbf{Outline the algorithm.} Write pseudo-code or flowcharts that
describe the computational steps.
\item
\textbf{Identify patterns or formulas.} Can loops, conditionals, or
equations be used to automate parts of the solution?
\end{itemize}
-\textbf{Example:} For processing stress-strain data: 1. Import data from
-a file. 2. Convert force and displacement to stress and strain. 3. Plot
-the stress-strain curve. 4. Identify the yield point or modulus.
+\subsubsection{Flowchart for fixing
+lamp}\label{flowchart-for-fixing-lamp}
-\subsection{Write \& Execute the Code}\label{write-execute-the-code}
+\begin{figure}
+\centering
+\includegraphics{figures/LampFlowchart.png}
+\caption{Lamp Flowchart}
+\end{figure}
-\begin{itemize}
+\subsubsection{Psuedo-Code for processing and plotting stress-strain
+data:}\label{psuedo-code-for-processing-and-plotting-stress-strain-data}
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
- \textbf{Choose the right tools.} Are there libraries I can use to get
- to my objective more effectively?
+ Import force and displacement data from file.
\item
- \textbf{Write modular code.} Use functions to separate different tasks
- (e.g., reading data, computing values, plotting).
+ Convert data from force and displacement to stress and strain.
\item
- \textbf{Check for syntax and logic errors.} Debug line-by-line using
- print statements or a debugger.
-\end{itemize}
+ Plot the stress-strain curve.
+\item
+ Identify the yield point or modulus.
+\end{enumerate}
-\textbf{Example:} Write a Python script that uses NumPy and Matplotlib
-to load a CSV file, compute stress and strain, and generate plots.
+\subsection{Write \& Execute the Code}\label{write-execute-the-code}
-\subsection{Test and Validate}\label{test-and-validate}
+When writing the code it is important to ask yourself whether you're
+using the right tools, libraries or method to solve the problem.
+\textbf{Check for any syntax and logic errors} then debug line-by-line
+using print statements or by using a debugging tool.
-\begin{itemize}
-\tightlist
-\item
- \textbf{Assess the feasibility of your results.} Do the values align
- with expected physical behavior?
-\item
- \textbf{Compare against established benchmarks.} Validate solutions
- using experimental data, literature values, or known theoretical
- limits.
-\item
- \textbf{Check units and scaling.} Ensure computations are consistent
- with physical meaning.
-\end{itemize}
+\subsection{Verify and Validate}\label{verify-and-validate}
-\textbf{Example:} If your plot shows stress values in the thousands when
-you expect hundreds, check unit conversions in your formula.
+When writing code it is crucial to test and confirm your code. It is
+therefore important to ask yourself the following questions. Does the
+code do what you intended it to do? And, is the mathematical model used
+in the code valid for the current problem?
-\subsection{Case Study: Simulating a Spring-Mass
-System}\label{case-study-simulating-a-spring-mass-system}
+\subsection{Exercise: Design a derivative finding
+algorithm}\label{exercise-design-a-derivative-finding-algorithm}
-\textbf{Scenario:} Model the motion of a mass-spring-damper system using
-a numerical solver.
+Set up the problem and write pseudo-code to calculate the gradient of an
+unknown function.
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
- \textbf{Define the Problem:} Set up the differential equation from
- Newton's Second Law.
-\item
- \textbf{Develop a Strategy:} Discretize time, apply numerical
- integration (e.g., Euler or Runge-Kutta).
+ \textbf{Given:}
\item
- \textbf{Execute the Code:} Write a Python function that computes
- motion over time.
+ **Find:
\item
- \textbf{Test the Model:} Compare results with analytical solutions for
- undamped or lightly damped systems.
+ \textbf{Assumptions:}
\item
- \textbf{Refine the Model:} Add adjustable damping and stiffness
- parameters.
+ \textbf{Solution:}
\item
- \textbf{Troubleshoot Issues:} If the model becomes unstable, reduce
- the time step or use a more accurate integrator.
+ \textbf{Comment:}
\end{enumerate}