1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
\section{Algorithmic thinking}\label{algorithmic-thinking}
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}
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{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
List your givens, this includes any constants or equations. What
inputs do we know?
\item
Find: List what you're trying to solve for. What outputs do we need to
find?
\item
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 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
\item
\textbf{Define the inputs and outputs.} What variables will the
program take in, and what results will it produce?
\item
\textbf{Break the problem into sub-tasks.} Identify steps such as data
input, logic processing and output.
\item
\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}
\subsubsection{Flowchart for fixing
lamp}\label{flowchart-for-fixing-lamp}
\begin{figure}
\centering
\includegraphics{figures/LampFlowchart.png}
\caption{Lamp Flowchart}
\end{figure}
\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
Import force and displacement data from file.
\item
Convert data from force and displacement to stress and strain.
\item
Plot the stress-strain curve.
\item
Identify the yield point or modulus.
\end{enumerate}
\subsection{Write \& Execute the Code}\label{write-execute-the-code}
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.
\subsection{Verify and Validate}\label{verify-and-validate}
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{Exercise: Design a derivative finding
algorithm}\label{exercise-design-a-derivative-finding-algorithm}
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{Given:}
\item
**Find:
\item
\textbf{Assumptions:}
\item
\textbf{Solution:}
\item
\textbf{Comment:}
\end{enumerate}
|