eulim 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eulim.gemspec +2 -2
- data/lib/eulim/chemical/reactors/reactor.rb +19 -2
- data/lib/eulim/chemistry/reaction.rb +7 -3
- data/lib/eulim/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a4ff2d9a51f17fe9a667eb929f4b4d40b17089a
|
4
|
+
data.tar.gz: b99d998f6b941096cc7f5dbd0fe5cc66ac3e6140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e6d1107d1d3f100b2a5202e36b8121417d01294e6c58e64cfa7473acbb04218e880bb4728dede64569a25ff6dd4fa252f40fef46cfbb5b92f6d265c40207780
|
7
|
+
data.tar.gz: a89714402c6448c539fd954a9b34f1931beb92aa9060cef227b4c4203ea5a1a9a69924ec8ef7b7898ea316adb3a95b16469660434ae161171455dbec6b8ab6da
|
data/eulim.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'eulim/version'
|
@@ -6,9 +7,8 @@ require 'eulim/version'
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = 'eulim'
|
8
9
|
spec.version = Eulim::VERSION
|
9
|
-
spec.authors = ['Syed Fazil Basheer','Somesh Choudhary']
|
10
|
+
spec.authors = ['Syed Fazil Basheer', 'Somesh Choudhary']
|
10
11
|
spec.email = ['fazil.basheer@quester.xyz', 'c.somesh5@gmail.com']
|
11
|
-
|
12
12
|
|
13
13
|
spec.summary = 'A gem for scientific data.'
|
14
14
|
spec.description = 'A gem for scientific data.'
|
@@ -8,19 +8,36 @@ module Eulim
|
|
8
8
|
def initialize(args = {})
|
9
9
|
@volume = volume_if_valid(args[:volume]) if args[:volume]
|
10
10
|
@system = args[:system] || :open
|
11
|
+
@input = input_if_valid(args[:input]) if args[:input]
|
11
12
|
end
|
12
13
|
|
13
14
|
private
|
14
15
|
|
15
16
|
def volume_if_valid(vol)
|
16
17
|
begin
|
17
|
-
vol = Unitwise
|
18
|
+
vol = Unitwise vol
|
18
19
|
rescue
|
19
|
-
raise ArgumentError, 'Invalid volume
|
20
|
+
raise ArgumentError, 'Invalid volume'
|
20
21
|
end
|
21
22
|
return vol if vol.composition.to_h == { 'L' => 3 }
|
22
23
|
raise ArgumentError, 'Invalid volume unit'
|
23
24
|
end
|
25
|
+
|
26
|
+
def input_if_valid(inp)
|
27
|
+
raise ArgumentError, 'Invalid input substance' if inp[:substance].class != Subs
|
28
|
+
begin
|
29
|
+
inp[:quantity] = Unitwise inp[:quantity]
|
30
|
+
rescue
|
31
|
+
raise ArgumentError, 'Invalid input quantity'
|
32
|
+
end
|
33
|
+
dim = inp[:quantity].composition.to_h
|
34
|
+
return inp if valid_input_quantity_compositions.include? dim
|
35
|
+
raise ArgumentError, 'Invalid input quantity unit'
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid_input_quantity_compositions
|
39
|
+
[{ 'M' => 1 }, { 'M' => 1, 'T' => -1 }, {}, { 'T' => -1 }]
|
40
|
+
end
|
24
41
|
end
|
25
42
|
end
|
26
43
|
end
|
@@ -5,7 +5,11 @@ module Eulim
|
|
5
5
|
class Reaction
|
6
6
|
attr_accessor :equation, :is_valid, :is_balanced, :species
|
7
7
|
|
8
|
-
STATES = {
|
8
|
+
STATES = {
|
9
|
+
'(s)' => 'solid', '(l)' => 'liquid',
|
10
|
+
'(g)' => 'gaseous', '(aq)' => 'aqueous',
|
11
|
+
'' => 'liquid'
|
12
|
+
}.freeze
|
9
13
|
|
10
14
|
def initialize(arg)
|
11
15
|
@equation = arg
|
@@ -14,7 +18,7 @@ module Eulim
|
|
14
18
|
@is_balanced = balanced_rxn?
|
15
19
|
end
|
16
20
|
|
17
|
-
|
21
|
+
private
|
18
22
|
|
19
23
|
def build_species
|
20
24
|
r = {}
|
@@ -34,7 +38,7 @@ module Eulim
|
|
34
38
|
st = get_state specie
|
35
39
|
offset_sc = sc.zero? ? 0 : sc.to_s.length
|
36
40
|
offset_st = st.empty? ? 0 : st.length
|
37
|
-
specie_str = specie[offset_sc..(specie.length - offset_st -1)]
|
41
|
+
specie_str = specie[offset_sc..(specie.length - offset_st - 1)]
|
38
42
|
{
|
39
43
|
specie_str => {
|
40
44
|
compound: Compound.new(specie_str),
|
data/lib/eulim/version.rb
CHANGED