num4mechaequ 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/num4mechaequ.rb +69 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e3e5fffadd5eea83945129ed1694e89bce4f636a077552c020806fbf60fa5f8
|
4
|
+
data.tar.gz: 4f8c45b1ccd5a0c2b88b4caf7c26d0febe7d82cad638aaeaddaae7b9f6b77829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5810693ced93a1143f50a9d1b418adc2b64435efd0d4cec33900938b5adb5105f34516f5de78ed115f340312ea40c0f814e9786968f747837abce17c1829c613
|
7
|
+
data.tar.gz: 592d88dc5d73c8dc48d1819097b3ce32e6fe33deede84f8308ab255254422e7c9d41f500a4e6c617b2ca29a62ea415c406942f20a5746e68c599b67a55cb2dd4
|
data/CHANGELOG.md
CHANGED
data/lib/num4mechaequ.rb
CHANGED
@@ -7,8 +7,10 @@ module Num4MechaEquLib
|
|
7
7
|
@g = 9.80665 # 重力加速度(m/s2)
|
8
8
|
@dt = 0.001 # 時間刻み
|
9
9
|
@w = 0.0
|
10
|
+
@l = 0.0
|
11
|
+
@ft = 0.0 # 外力
|
10
12
|
# 単振動
|
11
|
-
@
|
13
|
+
@SHMFunc = Proc.new do | n, yi |
|
12
14
|
f = []
|
13
15
|
f[0] = yi[1] # hの傾き値
|
14
16
|
f[1] = - @w * @w * yi[0] # vの傾き値
|
@@ -18,7 +20,7 @@ module Num4MechaEquLib
|
|
18
20
|
@motionFunc = Proc.new do | n, yi |
|
19
21
|
f = []
|
20
22
|
f[0] = yi[1] # hの傾き値
|
21
|
-
f[1] =
|
23
|
+
f[1] = @w * yi[1] - @g # vの傾き値
|
22
24
|
next f
|
23
25
|
end
|
24
26
|
# 放物運動
|
@@ -34,6 +36,20 @@ module Num4MechaEquLib
|
|
34
36
|
f[1] = - @g # vの傾き値
|
35
37
|
next f
|
36
38
|
end
|
39
|
+
# 減衰振動
|
40
|
+
@DHMFunc = Proc.new do | n, yi |
|
41
|
+
f = []
|
42
|
+
f[0] = yi[1]
|
43
|
+
f[1] = - @l * yi[1] - @w * @w * yi[0]
|
44
|
+
next f
|
45
|
+
end
|
46
|
+
# 強制振動
|
47
|
+
@forcedFunc = Proc.new do | n, yi |
|
48
|
+
f = []
|
49
|
+
f[0] = yi[1]
|
50
|
+
f[1] = - @w * @w * yi[0] + @ft
|
51
|
+
next f
|
52
|
+
end
|
37
53
|
class << self
|
38
54
|
|
39
55
|
#
|
@@ -52,7 +68,7 @@ module Num4MechaEquLib
|
|
52
68
|
yi_1 = []
|
53
69
|
yi = [h0, v0]
|
54
70
|
0.step(t, @dt) { |x|
|
55
|
-
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @dt, @
|
71
|
+
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @dt, @SHMFunc)
|
56
72
|
hvt.push({"t" => x,
|
57
73
|
"h" => yi_1[0], "v" => m * yi_1[1]})
|
58
74
|
yi = yi_1
|
@@ -149,7 +165,56 @@ module Num4MechaEquLib
|
|
149
165
|
# @return [hash[]] 0秒からt秒までの位置(h)と速度(v)の値
|
150
166
|
def pendulumMotion(m, l, t, h0, v0)
|
151
167
|
return SHM(m, l, t, h0, v0)
|
152
|
-
end
|
168
|
+
end
|
169
|
+
#
|
170
|
+
# 減衰振動(damped harmonic motion)
|
171
|
+
# @overload DHM(m, k, b, t, h0, v0)
|
172
|
+
# @param [double] m 重りの重さ
|
173
|
+
# @param [double] k 比例定数
|
174
|
+
# @param [double] b 抵抗力の比例定数
|
175
|
+
# @param [double] t 時間
|
176
|
+
# @param [double] h0 初期位置値
|
177
|
+
# @param [double] v0 初期速度
|
178
|
+
# @return [hash[]] 0秒からt秒までの位置(h)と速度(v)の値
|
179
|
+
def DHM(m, k, b, t, h0, v0)
|
180
|
+
@l = 2 * m * b
|
181
|
+
@w = Math.sqrt((k / m))
|
182
|
+
hvt = []
|
183
|
+
yi_1 = []
|
184
|
+
yi = [h0, v0]
|
185
|
+
0.step(t, @dt) { |x|
|
186
|
+
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @dt, @DHMFunc)
|
187
|
+
hvt.push({"t" => x,
|
188
|
+
"h" => yi_1[0], "v" => m * yi_1[1]})
|
189
|
+
yi = yi_1
|
190
|
+
}
|
191
|
+
return hvt
|
192
|
+
end
|
193
|
+
#
|
194
|
+
# 強制振動
|
195
|
+
# @overload forcedOscillation(m, k, w0, w, t, h0, v0)
|
196
|
+
# @param [double] m 重りの重さ
|
197
|
+
# @param [double] k 比例定数
|
198
|
+
# @param [double] w0 振動系の固有角振動
|
199
|
+
# @param [double] w 外力の角振動数
|
200
|
+
# @param [double] t 時間
|
201
|
+
# @param [double] h0 初期位置値
|
202
|
+
# @param [double] v0 初期速度
|
203
|
+
# @return [hash[]] 0秒からt秒までの位置(h)と速度(v)の値
|
204
|
+
def forcedOscillation(m, k, w0, w, t, h0, v0)
|
205
|
+
@w = Math.sqrt((k / m))
|
206
|
+
hvt = []
|
207
|
+
yi_1 = []
|
208
|
+
yi = [h0, v0]
|
209
|
+
0.step(t, @dt) { |x|
|
210
|
+
@ft = w / m * Math.cos(w * x)
|
211
|
+
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @dt, @forcedFunc)
|
212
|
+
hvt.push({"t" => x,
|
213
|
+
"h" => yi_1[0], "v" => m * yi_1[1]})
|
214
|
+
yi = yi_1
|
215
|
+
}
|
216
|
+
return hvt
|
217
|
+
end
|
153
218
|
end
|
154
219
|
end
|
155
220
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: num4mechaequ
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: num4simdiff
|
@@ -45,7 +45,7 @@ licenses:
|
|
45
45
|
- MIT
|
46
46
|
metadata:
|
47
47
|
changelog_uri: http://github.com/siranovel/num4mechaequation/blob/main/CHANGELOG.md
|
48
|
-
documentation_uri: https://rubydoc.info/gems/num4mechaequ/0.1.
|
48
|
+
documentation_uri: https://rubydoc.info/gems/num4mechaequ/0.1.3
|
49
49
|
homepage_uri: http://github.com/siranovel/num4mechaequation
|
50
50
|
wiki_uri: https://github.com/siranovel/mydocs/tree/main/num4phyequation/num4mechaequation
|
51
51
|
post_install_message:
|