-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·200 lines (184 loc) · 5.96 KB
/
index.html
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!doctype html>
<html>
<head>
<title>Spring Simulator</title>
<style type="text/css">
html, body {
padding: 0;
margin: 0;
}
body {
font-family: "times new roman", serif;
font-size: 17px;
overflow-y: scroll;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#spring {
position: fixed;
z-index: -1;
}
#controls {
border: 1px solid black;
background-color: white;
padding: 1em;
margin: 1em;
width: 450px;
position: absolute;
right: 0;
-webkit-box-shadow: 2px 2px 15px 0px rgba(0, 0, 0, .3);
box-shadow: 2px 2px 15px 0px rgba(0, 0, 0, .3);
}
.explanation {
font-size: 13px;
}
fieldset {
margin: 0.5em 0 2em;
}
fieldset:last-child {
margin-bottom: 0;
}
td {
padding: 4px 4px 4px 12px;
}
td:first-child {
text-align: center;
padding: 0;
width: 5px; /* as small as possible */
}
sup, sub {
font-size: 0.7em;
text-decoration: none !important;
}
.hanging {
display: inline-block;
vertical-align: text-top
}
#controls #omegaf, #controls #f-oscillating-function {
display: none;
}
#controls.f-oscillating #omegaf {
display: table-row;
}
#controls.f-oscillating #f-oscillating-function {
display: block;
}
#controls.f-oscillating #f .hanging {
vertical-align: top;
}
.sqrt {
border-top: 1px solid black;
}
.input[value="?"] {
opacity: 0.1
}
</style>
</head>
<body>
<div id="controls">
Mass-spring systems are governed by the following differential equation. Play with the variables or drag the mass itself!
<fieldset>
<legend><var>mx′′</var> + <var>bx′</var> + <var>kx</var> = <var>f</var>(<var>t</var>)</legend>
<table>
<tr id="m">
<td><input type="range" step="0.001" min="1" max="5" value="1" /></td>
<td>
<var>m</var> = <output></output> kg
<div class="explanation"><b>mass</b>: resistance to force</div>
</td>
</tr>
<tr id="b">
<td><input type="range" step="0.001" min="-5" max="3" value="-1.38629" /></Td>
<td>
<var>b</var> = <output></output> kg/s
<div class="explanation"><b>damping coefficient</b>: resistance to movement</div>
</td>
</tr>
<tr id="k">
<td><input type="range" step="0.001" min="1" max="5" value="3.912" /></td>
<td>
<var>k</var> = <output></output> kg/s<sup>2</sup>
<div class="explanation"><b>spring constant</b>: stiffness of spring</div>
</td>
</tr>
<tr id="f">
<td>
<input type="range" style="width: 20px; height: 100px; -webkit-appearance: slider-vertical" step="0.01" min="-5000" max="5000" value="0" />
</td>
<td>
<div style="line-height: 0.7em; padding-bottom: 0.3em">
<var>f</var>(<var>t</var>)
<div class="hanging">
<div id="f-oscillating-function">= <var>F</var><sub>0</sub> cos <var>ω</var><var>t</var></div>
<div>= <output></output> kg px/s<sup>2</sup></div>
</div>
</div>
<div class="explanation">
<b>forcing function</b>: external force on block <br />
<a href="#1" id="f-oscillation">turn oscillation on</a> |
<a href="#1" id="f-reset">reset <var>f</var>(<var>t</var>) = 0</a>
</div>
</td>
</tr>
<tr id="omegaf">
<td>
<canvas id="lorentzian"></canvas>
<input type="range" step="0.001" min="0" max="13" value="0" />
</td>
<td>
<var>ω</var> = <output></output> s<sup>−1</sup>
<div class="explanation">
<b>angular frequency of forcing function</b>
</div>
</td>
</table>
</fieldset>
We can find more information by rewriting the equation as:
<fieldset>
<legend><var>x</var>′′ + 2<var>ζω</var><sub>0</sub><var>x</var>′ + <var>ω</var><sub>0</sub><sup>2</sup><var>x</var> = <var>f</var>(<var>t</var>) / <var>m</var></legend>
<table>
<tr id="zeta">
<td><input type="range" step="0.001" min="0" max="2" disabled="disabled" /></td>
<td>
<var>ζ</var>
= <var>b</var> / 2√<span class="sqrt"><var>mk</var></span>
= <output></output>
<div class="explanation"><b>damping ratio</b>:
<div class="hanging">
system is underdamped if 0 < <var>ζ</var> < 1<br />
system is critically damped if <var>ζ</var> = 1<br />
system is overdamped if <var>ζ</var> > 1<br />
</div>
</div>
</td>
</tr>
<tr id="T">
<td><input type="range" step="0.001" min="0" max="8" disabled="disabled" /></td>
<td>
<var>T</var> = 2π / <var>ω</var><sub>1</sub> = <output></output> s
<div class="explanation"><b>period of motion</b>
</td>
</tr>
<tr id="omega0">
<td><input type="range" step="0.001" min="0" max="13" disabled="disabled" /></Td>
<td>
<var>ω</var><sub>0</sub> = √<span class="sqrt"><var>k / m</var></span> = <output></output> s<sup>−1</sup>
<div class="explanation"><b>natural angular frequency</b>: undamped frequency</div>
</td>
</tr>
<tr id="omega1">
<td><input type="range" step="0.001" min="0" max="13" disabled="disabled" /></td>
<td>
<var>ω</var><sub>1</sub> = <var>ω</var><sub>0</sub>√<span class="sqrt">1 - 2<var>ζ</var><sup>2</sup></span> = <output></output> s<sup>−1</sup>
<div class="explanation"><b>actual angular frequency</b> (<var>ω</var><sub>0</sub> ≈ <var>ω</var><sub>1</sub> for <var>ζ</var> ≪ 1)</div>
</td>
</tr>
</table>
</fieldset>
</div>
<canvas id="spring"></canvas>
<script src="spring.js" type="text/javascript"></script>
</body>
</html>