From dc13208abd61cc3ac7c64a4373f3ad85689f1293 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Tue, 29 Apr 2025 18:38:21 -0600 Subject: Finished of module 1 tutorials (.md) and added documentation to module 2 --- book/module2/problem_solving_strategies.tex | 145 ++++++++++++++-------------- 1 file changed, 70 insertions(+), 75 deletions(-) (limited to 'book/module2/problem_solving_strategies.tex') 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} -- cgit v1.2.3