num4mechaequ 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/num4mechaequ.rb +35 -8
- 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: 2924e1bd5f10cca8551f34b8d0e360206085627ebb69603c49df86bcf0777675
|
4
|
+
data.tar.gz: 0d74c4d37202716b4e43123dc10cd65c2862256bdbae7a95750f5d475a9faa39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce0e327685b176f86aa6f1fdca4d44c6c0144299cb27f6a312d44eece88258841380b54decc0b0bfaebd0fe373ffee2b42b4dc11cce863e0f81e0ea7096a9f4
|
7
|
+
data.tar.gz: 0c35ff365050615fec0cf67c1edc7981a2a6d944a4e00cabcda63f065f124c7b67e1b0ca2a5c8675a7a4c337a806850f3928351748162a15743ce7e69568903f
|
data/CHANGELOG.md
CHANGED
data/lib/num4mechaequ.rb
CHANGED
@@ -4,17 +4,23 @@ require 'num4simdiff'
|
|
4
4
|
# 数値計算による力学方程式の解法するライブラリ
|
5
5
|
#
|
6
6
|
module Num4MechaEquLib
|
7
|
-
@g = 9.
|
7
|
+
@g = 9.80665 # 重力加速度
|
8
8
|
@t = 0.001 # 時間刻み
|
9
|
-
@
|
10
|
-
@m = 0.0 # 重りの重さ
|
9
|
+
@w = 0.0
|
11
10
|
@springFunc = Proc.new do | n, yi |
|
12
11
|
f = []
|
13
|
-
f[0] = yi[1]
|
14
|
-
f[1] =
|
12
|
+
f[0] = yi[1] # hの傾き値
|
13
|
+
f[1] = @w * yi[0] - @g# vの傾き値
|
14
|
+
next f
|
15
|
+
end
|
16
|
+
@motionFunc = Proc.new do | n, yi |
|
17
|
+
f = []
|
18
|
+
f[0] = yi[1] # hの傾き値
|
19
|
+
f[1] = - @g # vの傾き値
|
15
20
|
next f
|
16
21
|
end
|
17
22
|
class << self
|
23
|
+
|
18
24
|
#
|
19
25
|
# バネの固有振動
|
20
26
|
# @overload springFreqEqu(k, m, h0, v0)
|
@@ -25,18 +31,39 @@ module Num4MechaEquLib
|
|
25
31
|
# @return [hash[]] 0秒から1秒までの位置(h)と速度(v)の値
|
26
32
|
#
|
27
33
|
def springFreqEqu(k, m, h0, v0)
|
28
|
-
@
|
29
|
-
@m = m
|
34
|
+
@w = Math.sqrt((k / m))
|
30
35
|
hvt = []
|
31
36
|
yi_1 = []
|
32
37
|
yi = [h0, v0]
|
33
38
|
0.step(1, @t) { |x|
|
34
39
|
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @t, @springFunc)
|
35
|
-
hvt.push({"t" => x,
|
40
|
+
hvt.push({"t" => x,
|
41
|
+
"h" => yi_1[0], "v" => m * yi_1[1]})
|
36
42
|
yi = yi_1
|
37
43
|
}
|
38
44
|
return hvt
|
39
45
|
end
|
46
|
+
#
|
47
|
+
# 自由落下による運動方程式(空気抵抗有り)
|
48
|
+
# @overload motiEqu4freeFallEqu(m, h0, v0)
|
49
|
+
# @param [double] m 重りの重さ
|
50
|
+
# @param [double] h0 初期位置値
|
51
|
+
# @param [double] v0 初期速度
|
52
|
+
# @return [hash[]] 0秒から1秒までの位置(h)と速度(v)の値
|
53
|
+
#
|
54
|
+
def motiEqu4freeFallEqu(m, h0, v0)
|
55
|
+
hvt = []
|
56
|
+
yi_1 = []
|
57
|
+
yi = [h0, v0]
|
58
|
+
0.step(1, @t) { |x|
|
59
|
+
yi_1 = Num4SimDiffLib.rungeKuttaMethod(yi, @t, @motionFunc)
|
60
|
+
hvt.push({"t" => x,
|
61
|
+
"h" => yi_1[0], "v" => m * yi_1[1]})
|
62
|
+
yi = yi_1
|
63
|
+
}
|
64
|
+
return hvt
|
65
|
+
|
66
|
+
end
|
40
67
|
end
|
41
68
|
end
|
42
69
|
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-08 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.0.
|
48
|
+
documentation_uri: https://rubydoc.info/gems/num4mechaequ/0.0.2
|
49
49
|
homepage_uri: http://github.com/siranovel/num4mechaequation
|
50
50
|
post_install_message:
|
51
51
|
rdoc_options: []
|