joules 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/joules/circular_motion.rb +1 -1
- data/lib/joules/constants.rb +1 -1
- data/lib/joules/conversion.rb +1 -1
- data/lib/joules/density.rb +1 -1
- data/lib/joules/electric_fields.rb +1 -1
- data/lib/joules/electricity.rb +1 -1
- data/lib/joules/energy_work_power.rb +1 -1
- data/lib/joules/forces.rb +1 -1
- data/lib/joules/geometry.rb +1 -1
- data/lib/joules/gravitational_fields.rb +1 -1
- data/lib/joules/kinematics.rb +1 -1
- data/lib/joules/magnetic_fields.rb +1 -1
- data/lib/joules/mass_weight.rb +1 -1
- data/lib/joules/momentum_impulse.rb +1 -1
- data/lib/joules/oscillations.rb +124 -0
- data/lib/joules/pressure.rb +1 -1
- data/lib/joules/quantum.rb +1 -1
- data/lib/joules/stress_strain.rb +1 -1
- data/lib/joules/thermodynamics.rb +1 -1
- data/lib/joules/waves.rb +5 -4
- data/lib/joules.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20266cc292103a7a4ec29036bf2eb5eca74653ea
|
4
|
+
data.tar.gz: df55eff3e23043443756fec9ea24ed7351313115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f744ec8a76f8a7fac6c7a74295eb01e8d3f29230729b5e447ec6f72d9c0dc6f25aa39dce9eb9c476a706a195196d1ba21932e27d52f9247aea646776836628db
|
7
|
+
data.tar.gz: 7f49d574908f32acb1c75332ee4f1e2d5f81413f4ad215049fc6122a820cd66386fc4039400b44857f08134bda28c136cf2fe6c254504cf0e9eb51d5fe2b175e
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ gem build joules.gemspec
|
|
15
15
|
|
16
16
|
### Library Installation
|
17
17
|
```Bash
|
18
|
-
gem install joules-0.4.
|
18
|
+
gem install joules-0.4.1.gem
|
19
19
|
```
|
20
20
|
|
21
21
|
### Library Import
|
@@ -69,6 +69,9 @@ This would return 23.4.
|
|
69
69
|
#### Version 0.4.0
|
70
70
|
* Added Physics formulas in circular motion
|
71
71
|
|
72
|
+
#### Version 0.4.1
|
73
|
+
* Added Physics formulas in oscillations
|
74
|
+
|
72
75
|
### Contribution
|
73
76
|
Please feel free to submit any ideas, questions, or problems by reporting an issue.
|
74
77
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing circular motion formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Circular motion module (circular_motion.rb)
|
data/lib/joules/constants.rb
CHANGED
data/lib/joules/conversion.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing conversion formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Conversion module (conversion.rb)
|
data/lib/joules/density.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing electric fields formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Electric fields module (electric_fields.rb)
|
data/lib/joules/electricity.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing electricity formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Electricity module (electricity.rb)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing energy, work, and power formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Energy, work, and power module (energy_work_power.rb)
|
data/lib/joules/forces.rb
CHANGED
data/lib/joules/geometry.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing gravitational fields formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Gravitational fields module (gravitational_fields.rb)
|
data/lib/joules/kinematics.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing kinematics formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Kinematics module (kinematics.rb)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing magnetic fields formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Magnetic fields module (magnetic_fields.rb)
|
data/lib/joules/mass_weight.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing mass and weight formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Mass and weight module (mass_weight.rb)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing momentum and impulse formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Momentum and impulse module (momentum_impulse.rb)
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#==============================================================================
|
2
|
+
# Joules
|
3
|
+
#
|
4
|
+
# @description: Module for providing oscillations formulas
|
5
|
+
# @author: Elisha Lai
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
|
+
#==============================================================================
|
8
|
+
|
9
|
+
# Oscillations module (oscillations.rb)
|
10
|
+
|
11
|
+
module Joules
|
12
|
+
module_function
|
13
|
+
|
14
|
+
# Calculates the acceleration of a particle in oscillation given angular velocity and particle displacement.
|
15
|
+
# @param angular_velocity [Int, Float]
|
16
|
+
# angular_velocity is in radians per second
|
17
|
+
# @param particle_displacement [Int, Float]
|
18
|
+
# particle_displacement is in metres
|
19
|
+
# @return [Float]
|
20
|
+
# return value is in metres per second squared
|
21
|
+
# @example
|
22
|
+
# Joules.particle_acceleration(2.4, 3) #=> -17.28
|
23
|
+
# @note There is one other method for calculating acceleration.
|
24
|
+
def particle_acceleration(angular_velocity, particle_displacement)
|
25
|
+
return (- (angular_velocity ** 2.0) * displacement)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Calculates the displacement of a particle in oscillation given amplitude, angular velocity, and time.
|
29
|
+
# @param amplitude [Int, Float]
|
30
|
+
# amplitude >= 0; amplitude is in metres
|
31
|
+
# @param angular_velocity [Int, Float]
|
32
|
+
# angular_velocity is in radians per second
|
33
|
+
# @param time [Int, Float]
|
34
|
+
# time >= 0; time is in seconds
|
35
|
+
# @return [Float]
|
36
|
+
# return value is in metres
|
37
|
+
# @example
|
38
|
+
# Joules.particle_displacement(5, 2.4, 3) #=> 3.041756572661276
|
39
|
+
def particle_displacement(amplitude, angular_velocity, time)
|
40
|
+
return amplitude * Math.cos(angular_velocity * time)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Calculates the velocity of a particle in oscillation given angular velocity, amplitude, and particle displacement.
|
44
|
+
# @param angular_velocity [Int, Float]
|
45
|
+
# angular_velocity is in radians per second
|
46
|
+
# @param amplitude [Int, Float]
|
47
|
+
# amplitude >= 0; amplitude is in metres
|
48
|
+
# @param particle_displacement [Int, Float]
|
49
|
+
# particle_displacement is in metres
|
50
|
+
# @param return_sign [String]
|
51
|
+
# return_sign is either '-' or '+'
|
52
|
+
# @return [Float, Array<Float>]
|
53
|
+
# return list has a length of 2; each velocity in return list or return value is in metres per second
|
54
|
+
# @example
|
55
|
+
# Joules.particle_velocity(2.4, 5, 3) #=> [9.6, -9.6]
|
56
|
+
def particle_velocity(angular_velocity, amplitude, particle_displacement, return_sign = nil)
|
57
|
+
return_value = angular_velocity * (((amplitude ** 2) - (particle_displacement ** 2)) ** 0.5)
|
58
|
+
if return_sign == '-'
|
59
|
+
return (- return_value)
|
60
|
+
elsif return_sign == '+'
|
61
|
+
return return_value
|
62
|
+
else
|
63
|
+
return [return_value, (- return_value)]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Calculates the maximum speed of a particle in oscillation given angular velocity and amplitude.
|
68
|
+
# @param angular_velocity [Int, Float]
|
69
|
+
# angular_velocity is in radians per second
|
70
|
+
# @param amplitude [Int, Float]
|
71
|
+
# amplitude >= 0; amplitude is in metres
|
72
|
+
# @return [Float]
|
73
|
+
# return value is in metres per second
|
74
|
+
# @example
|
75
|
+
# Joules.maximum_speed(2.4, 5) #=> 12.0
|
76
|
+
def max_particle_speed(angular_velocity, amplitude)
|
77
|
+
return angular_velocity * amplitude.to_f
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates the maximum acceleration of a particle in oscillation given angular velocity and amplitude.
|
81
|
+
# @param angular_velocity [Int, Float]
|
82
|
+
# angular_velocity is in radians per second
|
83
|
+
# @param amplitude [Int, Float]
|
84
|
+
# amplitude >= 0; amplitude is in metres
|
85
|
+
# @return [Float]
|
86
|
+
# return value >= 0; return value is in metres per second squared
|
87
|
+
# @example
|
88
|
+
# Joules.maximum_acceleration(2.4, 5) #=> 28.799999999999997
|
89
|
+
def max_particle_acceleration(angular_velocity, amplitude)
|
90
|
+
return (angular_velocity ** 2.0) * amplitude
|
91
|
+
end
|
92
|
+
|
93
|
+
# Calculates the time period of a mass-spring system given mass and spring constant.
|
94
|
+
# @param mass [Int, Float]
|
95
|
+
# mass >= 0; mass is in kilograms
|
96
|
+
# @param spring_constant [Int, Float]
|
97
|
+
# spring_constant > 0; spring_constant is in newtons per metre
|
98
|
+
# @return [Float]
|
99
|
+
# return value >= 0; return value is in seconds
|
100
|
+
# @raise [ZeroDivisionError] if spring_constant = 0
|
101
|
+
# @example
|
102
|
+
# Joules.time_period_v2(20, 5) #=> 12.566370614359172
|
103
|
+
# @note There are two other methods for calculating time period.
|
104
|
+
def time_period_v2(mass, spring_constant)
|
105
|
+
if spring_constant.zero?
|
106
|
+
raise ZeroDivisionError.new('divided by 0')
|
107
|
+
else
|
108
|
+
return 2 * Math::PI * ((mass / spring_constant.to_f) ** 0.5)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Calculates the time period of a simple pendulum given pendulum length.
|
113
|
+
# @param pendulum_length [Int, Float]
|
114
|
+
# pendulum_length >= 0; pendulum_length is in metres
|
115
|
+
# @return [Float]
|
116
|
+
# return value >= 0; return value is in seconds
|
117
|
+
# @example
|
118
|
+
# Joules.time_period_v3(8.4) #=> 5.814133609631141
|
119
|
+
# @note There are two other methods for calculating time period.
|
120
|
+
def time_period_v3(pendulum_length)
|
121
|
+
return 2 * Math::PI * ((pendulum_length / FREE_FALL_ACCELERATION) ** 0.5)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
data/lib/joules/pressure.rb
CHANGED
data/lib/joules/quantum.rb
CHANGED
data/lib/joules/stress_strain.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing stress and strain formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Stress and strain module (stress_strain.rb)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing thermodynamics formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Thermodynamics module (thermodynamics.rb)
|
data/lib/joules/waves.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing waves formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Waves module (waves.rb)
|
@@ -82,11 +82,12 @@ module Joules
|
|
82
82
|
# @param frequency [Int, Float]
|
83
83
|
# frequency > 0; frequency is in hertz
|
84
84
|
# @return [Float]
|
85
|
-
# return value > 0; return value is in
|
85
|
+
# return value > 0; return value is in seconds
|
86
86
|
# @raise [ZeroDivisionError] if frequency = 0
|
87
87
|
# @example
|
88
|
-
# Joules.
|
89
|
-
|
88
|
+
# Joules.time_period_v1(0.08) #=> 12.5
|
89
|
+
# @note There are two other methods for calculating time period.
|
90
|
+
def time_period_v1(frequency)
|
90
91
|
if frequency.zero?
|
91
92
|
raise ZeroDivisionError.new('divided by 0')
|
92
93
|
else
|
data/lib/joules.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# @description: Module for providing Physics formulas
|
5
5
|
# @author: Elisha Lai
|
6
|
-
# @version: 0.4.
|
6
|
+
# @version: 0.4.1 07/06/2015
|
7
7
|
#==============================================================================
|
8
8
|
|
9
9
|
# Joules module (joules.rb)
|
@@ -20,6 +20,7 @@ require 'joules/stress_strain'
|
|
20
20
|
require 'joules/pressure'
|
21
21
|
require 'joules/thermodynamics'
|
22
22
|
require 'joules/waves'
|
23
|
+
require 'joules/oscillations'
|
23
24
|
require 'joules/electricity'
|
24
25
|
require 'joules/quantum'
|
25
26
|
require 'joules/gravitational_fields'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elisha Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " Joules is a library (gem) for providing simple Physics formulas\n
|
14
14
|
\ in kinematics, forces, waves, electricity, and so much more. A\n selection
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/joules/magnetic_fields.rb
|
36
36
|
- lib/joules/mass_weight.rb
|
37
37
|
- lib/joules/momentum_impulse.rb
|
38
|
+
- lib/joules/oscillations.rb
|
38
39
|
- lib/joules/pressure.rb
|
39
40
|
- lib/joules/quantum.rb
|
40
41
|
- lib/joules/stress_strain.rb
|