Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added eqn images
  • Loading branch information
rcc02007 committed Sep 21, 2017
1 parent 9c1c958 commit 162abcd
Show file tree
Hide file tree
Showing 22 changed files with 551 additions and 578 deletions.
507 changes: 222 additions & 285 deletions 08_optimization/.ipynb_checkpoints/lecture_08-checkpoint.ipynb

Large diffs are not rendered by default.

507 changes: 222 additions & 285 deletions 08_optimization/lecture_08.ipynb

Large diffs are not rendered by default.

Binary file modified 08_optimization/octave-workspace
Binary file not shown.
77 changes: 77 additions & 0 deletions HW2/README.html
@@ -0,0 +1,77 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</head>
<body>
<h1 id="homework-2">Homework #2</h1>
<h2 id="due-10617-by-1159pm">due 10/6/17 by 11:59pm</h2>
<p><strong>1.</strong> Create a new github repository called ‘02_roots_and_optimization’.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Add rcc02007 and zhs15101 as collaborators.</p></li>
<li><p>submit the clone repository URL to: <a href="https://goo.gl/forms/svFKpfiCfLO9Zvfz1" class="uri">https://goo.gl/forms/svFKpfiCfLO9Zvfz1</a></p></li>
</ol>
<p><strong>2.</strong> You’re installing a powerline in a residential neighborhood. The lowest point on the cable is 30 m above the ground, but 30 m away is a tree that is 35 m tall. Another engineer informs you that this is a catenary cable problem with the following solution</p>
<div class="figure">
<img src="./equations/eq1.png" alt="eq. 1" />
<p class="caption">eq. 1</p>
</div>
<p><span class="math inline">\(y(x)=\frac{T}{w}\cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}\)</span>.</p>
<p>where y(x) is the height of the cable at a distance, x, from the lowest point, <span class="math inline">\(y_{0}\)</span>, T is the tension in the cable, and w is the weight per unit length of the cable. Your supervisor wants to know which numerical solver to use when they have to install these powerlines in similar places.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Use the three solvers <code>falsepos.m</code>, <code>bisect.m</code>, and <code>mod_secant.m</code> to solve for the tension neededi, T, to reach y(30 m)=35 m, with w=10 N/m, and <span class="math inline">\(y_{0}\)</span>=30 m.</p></li>
<li><p>Compare the number of iterations that each function needed to reach an accuracy of 0.00001%. Include a table in your README.md with:</p>
<pre><code>| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos | | | |
|mod_secant | | | |
|bisect | | | |</code></pre></li>
<li><p>Add a figure to your README that plots the final shape of the powerline (<img src="./equations/eq2.png" alt="eq2" />) from x=-10 to 50 m.</p></li>
</ol>
<p><strong>3.</strong> The Newton-Raphson method and the modified secant method do not always converge to a solution. One simple example is the function f(x) = (x-1)*exp(-(x-1)^2). The root is at 1, but using the numerical solvers, <code>newtraph.m</code> and <code>mod_secant.m</code>, there are certain initial guesses that do not converge.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Calculate the first 5 iterations for the Newton-Raphson method with an initial guess of x_i=3 for f(x)=(x-1)*exp(-(x-1)^2).</p></li>
<li><p>Add the results to a table in the <code>README.md</code> with:</p>
<pre><code>### divergence of Newton-Raphson method

| iteration | x_i | approx error |
| --- | --- | --- |
| 0 | 3 | n/a |
| 1 | | |
| 2 | | |
| 3 | | |
| 4 | | |
| 5 | | |</code></pre></li>
<li><p>Repeat steps a-b for an initial guess of 1.2. (But change the heading from ‘divergence’ to ‘convergence’)</p></li>
</ol>
<div class="figure">
<img src="../08_optimization/Auchain_model.png" alt="Model of Gold chain, from molecular dynamics simulation" />
<p class="caption">Model of Gold chain, from molecular dynamics simulation</p>
</div>
<p><strong>4.</strong> Determine the nonlinear spring constants of a single-atom gold chain. You can assume the gold atoms are aligned in a one dimensional network and the potential energy is described by the Lennard-Jones potential as such</p>
<div class="figure">
<img src="./equations/eq3.png" alt="eq3" />
<p class="caption">eq3</p>
</div>
<p><span class="math inline">\(E_{LJ}(x)=4\epsilon \left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)\)</span>.</p>
<p>Where x is the distance between atoms in nm, <span class="math inline">\(\epsilon\)</span>=2.71E-4 aJ, and <span class="math inline">\(\sigma\)</span>=0.2934 nm. The energy term that must be minimized is</p>
<div class="figure">
<img src="./equations/eq4.png" alt="eq4" />
<p class="caption">eq4</p>
</div>
<p><span class="math inline">\(E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x\)</span>.</p>
<p>Where <span class="math inline">\(x_{0}\)</span> is the distance between atoms with no force applied and <img src="./equations/deltax.png" alt="dx" /> is the amount each gold atom has moved under a given force, F.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Determine <img src="./equations/x0.png" alt="x0" /> when F=0 nN using the golden ratio and parabolic methods. <em>Show your script and output in your README and include your functions</em></p></li>
<li><p>Solve for <img src="./equations/deltax.png" alt="dx" /> is the amount each gold atom has mov for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio solver or the matlab/octave <code>fminsearch</code></p></li>
<li><p>create a sum of squares error function <code>sse_of_parabola.m</code> that calculates the sum of squares error between a function <span class="math inline">\(F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}\)</span> and the Forces used in part B for each <img src="./equations/deltax.png" alt="dx" />.</p></li>
<li><p>Use the <code>fminsearch</code> matlab/octave function to determine <img src="./equations/k1k2.png" alt="k1k2" />.</p></li>
<li><p>Plot the force vs calculated <img src="./equations/deltax.png" alt="dx" /> and the best-fit parabola using <img src="./equations/k1k2.png" alt="k1k2" /> in part d.</p></li>
</ol>
</body>
</html>
24 changes: 16 additions & 8 deletions HW2/README.md
Expand Up @@ -14,6 +14,8 @@
cable is 30 m above the ground, but 30 m away is a tree that is 35 m tall. Another
engineer informs you that this is a catenary cable problem with the following solution

![eq. 1](./equations/eq1.png)

$y(x)=\frac{T}{w}\cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}$.

where y(x) is the height of the cable at a distance, x, from the lowest point, $y_{0}$,
Expand All @@ -37,7 +39,7 @@ engineer informs you that this is a catenary cable problem with the following so


c. Add a figure to your README that plots the final shape of the powerline
($y(x)~vs.~x$) from x=-10 to 50 m.
(![eq2](./equations/eq2.png)) from x=-10 to 50 m.

**3\.** The Newton-Raphson method and the modified secant method do not always converge to a
solution. One simple example is the function f(x) = (x-1)*exp(-(x-1)^2). The root is at 1, but
Expand Down Expand Up @@ -71,29 +73,35 @@ guesses that do not converge.
the gold atoms are aligned in a one dimensional network and the potential energy is
described by the Lennard-Jones potential as such

![eq3](./equations/eq3.png)

$E_{LJ}(x)=4\epsilon
\left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)$.

Where x is the distance between atoms in nm, $\epsilon$=2.71E-4 aJ, and $\sigma$=0.2934
nm. The energy term that must be minimized is

![eq4](./equations/eq4.png)

$E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x$.

Where $x_{0}$ is the distance between atoms with no force applied and $\Delta x$ is the
Where ![x0](./equations/x0.png) is the distance between atoms with no force applied and
![dx](./equations/deltax.png) is the
amount each gold atom has moved under a given force, F.

a. Determine $x_{0}$ when F=0 nN using the golden ratio and parabolic methods. *Show
a. Determine ![x0](./equations/x0.png) when F=0 nN using the golden ratio and parabolic methods. *Show
your script and output in your README and include your functions*

b. Solve for $\Delta x$ for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio
b. Solve for ![dx](./equations/deltax.png) is the
amount each gold atom has mov for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio
solver or the matlab/octave `fminsearch`

c. create a sum of squares error function `sse_of_parabola.m` that calculates the sum of
squares error between a function $F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}$ and the
Forces used in part B for each $\Delta x$.
Forces used in part B for each ![dx](./equations/deltax.png).

d. Use the `fminsearch` matlab/octave function to determine $K_{1}$ and $K_{2}$.
d. Use the `fminsearch` matlab/octave function to determine
![k1k2](./equations/k1k2.png).

e. Plot the force vs calculated $\Delta x$ and the best-fit parabola using $K_{1}$ and
$K_{2}$ in part d.
e. Plot the force vs calculated ![dx](./equations/deltax.png) and the best-fit parabola using ![k1k2](./equations/k1k2.png) in part d.

Empty file added HW2/equations/README.md
Empty file.
Binary file added HW2/equations/deltax.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions HW2/equations/deltax.tex
@@ -0,0 +1 @@
$\Delta x$
Binary file added HW2/equations/eq1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions HW2/equations/eq1.tex
@@ -0,0 +1,2 @@
$y(x)=T/w \cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}$.

Binary file added HW2/equations/eq2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions HW2/equations/eq2.tex
@@ -0,0 +1,2 @@
($y(x)~vs.~x$)

Binary file added HW2/equations/eq3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions HW2/equations/eq3.tex
@@ -0,0 +1,3 @@
$E_{LJ}(x)=4\epsilon
\left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)$.

Binary file added HW2/equations/eq4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions HW2/equations/eq4.tex
@@ -0,0 +1,2 @@
$E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x$.

Binary file added HW2/equations/fx.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions HW2/equations/fx.tex
@@ -0,0 +1,2 @@
$F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}$

Binary file added HW2/equations/k1k2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions HW2/equations/k1k2.tex
@@ -0,0 +1 @@
$K_{1}$ and $K_{2}$
Binary file added HW2/equations/x0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions HW2/equations/x0.tex
@@ -0,0 +1 @@
$x_{0}$

0 comments on commit 162abcd

Please sign in to comment.