crystalcell 0.0.3 → 0.0.4
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 +7 -0
- data/CHANGES +23 -1
- data/Gemfile +9 -9
- data/VERSION +1 -1
- data/crystalcell.gemspec +41 -29
- data/lib/crystalcell/atom.rb +116 -118
- data/lib/crystalcell/cell.rb +542 -586
- data/lib/crystalcell/element.rb +49 -140
- data/lib/crystalcell/latticeaxes.rb +198 -185
- data/lib/crystalcell/periodiccell.rb +246 -244
- data/lib/crystalcell/povray/cell.rb +110 -0
- data/lib/crystalcell/povray/cylinder.rb +12 -0
- data/lib/crystalcell/povray/element.rb +284 -0
- data/lib/crystalcell/povray/sphere.rb +12 -0
- data/lib/crystalcell/povray/triangle.rb +17 -0
- data/lib/crystalcell/povray.rb +7 -0
- data/lib/crystalcell.rb +5 -1
- data/test/povray/test_cell.rb +179 -0
- data/test/povray/test_element.rb +230 -0
- data/test/test_atom.rb +198 -198
- data/test/test_cell.rb +1481 -1464
- data/test/test_element.rb +422 -642
- data/test/test_latticeaxes.rb +299 -283
- data/test/test_periodiccell.rb +928 -953
- metadata +63 -62
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db6d8120f97d6fa22fe9fe5095bb3f848a75e8ba
|
4
|
+
data.tar.gz: 9aee254b92a6c89df45b3459bc30f35297a3c4b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a5158acc279b9f2bfd7bca995e0584e9afb34ddbab6aa9e48ea9c1d3b4a868589b0c502679900d1f2869730b4b1cc2d0a2414ff81e24a683d689462ca8896b3
|
7
|
+
data.tar.gz: 68a56c0ea4bf4eb2ee5f58a40727b4df5c9697ea0aad93cecf6a71c65193adcd5cff4713c9eaa0ff00f16409bd8f8fc81fa2e4ad22d868e0fc0b256a4ed5e3b9
|
data/CHANGES
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
= crystalcell Changelog
|
2
2
|
|
3
|
-
== Master (for 0.0.
|
3
|
+
== Master (for 0.0.5)
|
4
|
+
|
5
|
+
== Version 0.0.4 [2016-03-11] released
|
6
|
+
* LatticeAxes.axes is added.
|
7
|
+
* LatticeAxes.* is added.
|
8
|
+
* LatticeAxes.to_a is added.
|
9
|
+
|
10
|
+
* CrystalCell::Povray::Cell is added
|
11
|
+
* CrystalCell::Povray::Cylinder is added
|
12
|
+
* CrystalCell::Povray::Element is added
|
13
|
+
* CrystalCell::Povray::Sphere is added
|
14
|
+
* CrystalCell::Povray::Triangle is added
|
15
|
+
|
16
|
+
* CrystalCell::Element
|
17
|
+
* remove get*() methods.
|
18
|
+
* remove include? methods.
|
19
|
+
* add symbol_to_num method
|
20
|
+
* add num_to_symbol method
|
21
|
+
* rename radius to atomic_radius
|
22
|
+
|
23
|
+
* CrystalCell::PeriodicCell.find_bonds returns preserved order of elements
|
24
|
+
|
25
|
+
== Version 0.0.3 [2015-02-05] released
|
4
26
|
* Add CrystalCell::LatticeAxes.new_lc
|
5
27
|
|
6
28
|
== Version 0.0.2 [2014-08-30] released
|
data/Gemfile
CHANGED
@@ -6,13 +6,13 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "
|
10
|
-
gem "
|
11
|
-
gem "
|
12
|
-
gem "
|
13
|
-
gem "
|
14
|
-
gem "
|
15
|
-
gem "
|
16
|
-
gem "
|
17
|
-
|
9
|
+
gem "test-unit", "~> 3.1"
|
10
|
+
gem "rdoc", "~> 4.2"
|
11
|
+
gem "bundler", "~> 1.11"
|
12
|
+
gem "jeweler", "~> 2.0"
|
13
|
+
gem "simplecov", "~> 0.11"
|
14
|
+
gem "malge", "~> 0.0"
|
15
|
+
gem "mageo", "~> 0.0"
|
16
|
+
gem "maset", "~> 0.0"
|
17
|
+
gem "builtinextension", "~> 0.1"
|
18
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/crystalcell.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: crystalcell 0.0.4 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "crystalcell"
|
8
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.4"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["ippei94da"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2016-03-10"
|
13
15
|
s.description = "This gem provides Cell, LatticeAxes, Atom classes, and so on.\n And this provides simple treatment of a periodic boundary condition.\n "
|
14
16
|
s.email = "ippei94da@gmail.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -31,8 +33,16 @@ Gem::Specification.new do |s|
|
|
31
33
|
"lib/crystalcell/element.rb",
|
32
34
|
"lib/crystalcell/latticeaxes.rb",
|
33
35
|
"lib/crystalcell/periodiccell.rb",
|
36
|
+
"lib/crystalcell/povray.rb",
|
37
|
+
"lib/crystalcell/povray/cell.rb",
|
38
|
+
"lib/crystalcell/povray/cylinder.rb",
|
39
|
+
"lib/crystalcell/povray/element.rb",
|
40
|
+
"lib/crystalcell/povray/sphere.rb",
|
41
|
+
"lib/crystalcell/povray/triangle.rb",
|
34
42
|
"test/cif/ZrO2-25C.cif",
|
35
43
|
"test/helper.rb",
|
44
|
+
"test/povray/test_cell.rb",
|
45
|
+
"test/povray/test_element.rb",
|
36
46
|
"test/test_atom.rb",
|
37
47
|
"test/test_cell.rb",
|
38
48
|
"test/test_element.rb",
|
@@ -41,41 +51,43 @@ Gem::Specification.new do |s|
|
|
41
51
|
]
|
42
52
|
s.homepage = "http://github.com/ippei94da/crystalcell"
|
43
53
|
s.licenses = ["MIT"]
|
44
|
-
s.
|
45
|
-
s.rubygems_version = "1.8.23"
|
54
|
+
s.rubygems_version = "2.5.1"
|
46
55
|
s.summary = "Classes around a cell in crystallography"
|
47
56
|
|
48
57
|
if s.respond_to? :specification_version then
|
49
|
-
s.specification_version =
|
58
|
+
s.specification_version = 4
|
50
59
|
|
51
60
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_development_dependency(%q<
|
53
|
-
s.add_development_dependency(%q<
|
54
|
-
s.add_development_dependency(%q<
|
55
|
-
s.add_development_dependency(%q<
|
56
|
-
s.add_development_dependency(%q<
|
57
|
-
s.add_development_dependency(%q<
|
58
|
-
s.add_development_dependency(%q<
|
59
|
-
s.add_development_dependency(%q<
|
61
|
+
s.add_development_dependency(%q<test-unit>, ["~> 3.1"])
|
62
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.2"])
|
63
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.11"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
65
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.11"])
|
66
|
+
s.add_development_dependency(%q<malge>, ["~> 0.0"])
|
67
|
+
s.add_development_dependency(%q<mageo>, ["~> 0.0"])
|
68
|
+
s.add_development_dependency(%q<maset>, ["~> 0.0"])
|
69
|
+
s.add_development_dependency(%q<builtinextension>, ["~> 0.1"])
|
60
70
|
else
|
61
|
-
s.add_dependency(%q<
|
62
|
-
s.add_dependency(%q<
|
63
|
-
s.add_dependency(%q<
|
64
|
-
s.add_dependency(%q<
|
65
|
-
s.add_dependency(%q<
|
66
|
-
s.add_dependency(%q<
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
71
|
+
s.add_dependency(%q<test-unit>, ["~> 3.1"])
|
72
|
+
s.add_dependency(%q<rdoc>, ["~> 4.2"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.11"])
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
75
|
+
s.add_dependency(%q<simplecov>, ["~> 0.11"])
|
76
|
+
s.add_dependency(%q<malge>, ["~> 0.0"])
|
77
|
+
s.add_dependency(%q<mageo>, ["~> 0.0"])
|
78
|
+
s.add_dependency(%q<maset>, ["~> 0.0"])
|
79
|
+
s.add_dependency(%q<builtinextension>, ["~> 0.1"])
|
69
80
|
end
|
70
81
|
else
|
71
|
-
s.add_dependency(%q<
|
72
|
-
s.add_dependency(%q<
|
73
|
-
s.add_dependency(%q<
|
74
|
-
s.add_dependency(%q<
|
75
|
-
s.add_dependency(%q<
|
76
|
-
s.add_dependency(%q<
|
77
|
-
s.add_dependency(%q<
|
78
|
-
s.add_dependency(%q<
|
82
|
+
s.add_dependency(%q<test-unit>, ["~> 3.1"])
|
83
|
+
s.add_dependency(%q<rdoc>, ["~> 4.2"])
|
84
|
+
s.add_dependency(%q<bundler>, ["~> 1.11"])
|
85
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
86
|
+
s.add_dependency(%q<simplecov>, ["~> 0.11"])
|
87
|
+
s.add_dependency(%q<malge>, ["~> 0.0"])
|
88
|
+
s.add_dependency(%q<mageo>, ["~> 0.0"])
|
89
|
+
s.add_dependency(%q<maset>, ["~> 0.0"])
|
90
|
+
s.add_dependency(%q<builtinextension>, ["~> 0.1"])
|
79
91
|
end
|
80
92
|
end
|
81
93
|
|
data/lib/crystalcell/atom.rb
CHANGED
@@ -6,125 +6,123 @@ raise "Atom class need ruby version later than 1.9." if RUBY_VERSION.to_f < 1.9
|
|
6
6
|
# This class is not assumeed in a periodic condition.
|
7
7
|
class CrystalCell::Atom
|
8
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
|
-
3.times do |i|
|
62
|
-
return false if ((atom0.position[i] - atom1.position[i]).abs > tol)
|
63
|
-
end
|
64
|
-
return true
|
65
|
-
end
|
66
|
-
|
67
|
-
## Instance methods
|
68
|
-
|
69
|
-
# Restricted equivalence checking.
|
70
|
-
# Return true when all the condition below are satisfied:
|
71
|
-
# - same element identifier.
|
72
|
-
# - difference of coordinates is the same.
|
73
|
-
# This method should be used after well-consideration.
|
74
|
-
# Arbitrary coordinates are not generally the same like Float instances.
|
75
|
-
# It is a good idea to use in test scripts.
|
76
|
-
def ==(other)
|
77
|
-
#pp self
|
78
|
-
#pp other
|
79
|
-
self.class.equal_in_delta?(self, other, 0.0)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Equivalence checking (instance method version) .
|
83
|
-
# Return true when all the condition below are satisfied:
|
84
|
-
# - same element identifier.
|
85
|
-
# - difference of coordinates is within tolerance.
|
86
|
-
def equal_in_delta?(other, tol = 0.0)
|
87
|
-
self.class.equal_in_delta?(self, other, tol)
|
88
|
-
end
|
89
|
-
|
90
|
-
#Return Vector3DInternal instance consist of coordinates between 0 and 1.
|
91
|
-
def internal_coordinates
|
92
|
-
result = @position.map{ |coord| coord - coord.floor }
|
93
|
-
return Vector3DInternal[ *result ]
|
94
|
-
end
|
95
|
-
|
96
|
-
# Return Vector3DInternal instance consist of integers,
|
97
|
-
# by which self.internal_coordinates translate to self.position.
|
98
|
-
def translation_symmetry_operation
|
99
|
-
result = @position.map{ |coord| coord.floor }
|
100
|
-
return Vector3DInternal[ *result ]
|
101
|
-
end
|
102
|
-
|
103
|
-
# Overwrite position.
|
104
|
-
def set_position(position)
|
105
|
-
#pp position
|
106
|
-
#pp position.class
|
107
|
-
raise TypeError, "#{position.class}" if position.class == Vector3D
|
108
|
-
@position = position.to_v3di
|
109
|
-
end
|
110
|
-
|
111
|
-
# Translate atom position (destructive).
|
112
|
-
# Argument 'vec' should be given as internal vector,
|
113
|
-
# which is an Array or Vector3DInternal instance but Vector3D instance.
|
114
|
-
def translate!(vec)
|
115
|
-
raise TypeError if vec.class == Vector3D
|
116
|
-
raise TypeError if vec.size != 3
|
117
|
-
self.set_position(@position + Vector3DInternal[ *vec ])
|
118
|
-
end
|
119
|
-
|
120
|
-
# Translate atom position (nondestructive).
|
121
|
-
# Argument 'vec' should be given as internal vector,
|
122
|
-
# which is an Array or Vector3DInternal instance but Vector3D instance.
|
123
|
-
def translate(vec)
|
124
|
-
tmp = Marshal.load(Marshal.dump(self))
|
125
|
-
tmp.translate!(vec)
|
126
|
-
return tmp
|
9
|
+
include Mageo
|
10
|
+
|
11
|
+
class TypeError < StandardError ; end
|
12
|
+
|
13
|
+
# Do not change :position to attr_accessor.
|
14
|
+
# This must be Vector3DInternal instance.
|
15
|
+
attr_reader :movable_flags
|
16
|
+
attr_accessor :element, :name, :position
|
17
|
+
|
18
|
+
# Arguments:
|
19
|
+
# elements:
|
20
|
+
# Identifier of a element.
|
21
|
+
# This may be String like "Li", Integer like 0, or other class instances.
|
22
|
+
# Why doesn't this class have concrete name of elements?
|
23
|
+
# The reason is below:
|
24
|
+
# - This class is assumed to be used in Cell class instances.
|
25
|
+
# When we treat symmetry of the cell, the elements of atoms are not necessary information.
|
26
|
+
# This specification enable highly abstract level of treatment of cells.
|
27
|
+
# - POSCAR file of VASP (before ver.4 series) don't have element information.
|
28
|
+
# This specification enable to use POSCAR directly without POTCAR or element indication.
|
29
|
+
# position:
|
30
|
+
# Coordinates of an atom.
|
31
|
+
# This argument 'position' is mainly assumed as a internal coordinate.
|
32
|
+
# name:
|
33
|
+
# Identifier of an atom, e.g., "Li1" or "O23".
|
34
|
+
# movable_flags:
|
35
|
+
# Movable flags of an atom in each of three directions as a Array of three items.
|
36
|
+
def initialize(element, position, name = nil, movable_flags = nil)
|
37
|
+
raise TypeError, "Position doesn't have []: (#{position.inspect})" unless position.methods.include?(:[])
|
38
|
+
raise TypeError, "Number of items in position is not 3: (#{position})" if position.size != 3
|
39
|
+
raise TypeError, "Coordinate is not a Float: (#{position})" if position[0].class != Float
|
40
|
+
raise TypeError, "Coordinate is not a Float: (#{position})" if position[1].class != Float
|
41
|
+
raise TypeError, "Coordinate is not a Float: (#{position})" if position[2].class != Float
|
42
|
+
|
43
|
+
@element = element
|
44
|
+
set_position(position)
|
45
|
+
@name = name
|
46
|
+
@movable_flags = movable_flags
|
47
|
+
end
|
48
|
+
|
49
|
+
## Class methods
|
50
|
+
|
51
|
+
# Equivalence checking (class method version).
|
52
|
+
# Return true when all the condition below are satisfied:
|
53
|
+
# - same element identifier.
|
54
|
+
# - difference of coordinates is within tolerance.
|
55
|
+
# Note that distance cannot be used since this class doesn't have a lattice axes.
|
56
|
+
# Imagine the shape of tolerant zone is a hexahedron.
|
57
|
+
def self.equal_in_delta?(atom0, atom1, tol = 0.0)
|
58
|
+
return false if atom0.element != atom1.element
|
59
|
+
3.times do |i|
|
60
|
+
return false if ((atom0.position[i] - atom1.position[i]).abs > tol)
|
127
61
|
end
|
62
|
+
return true
|
63
|
+
end
|
64
|
+
|
65
|
+
## Instance methods
|
66
|
+
|
67
|
+
# Restricted equivalence checking.
|
68
|
+
# Return true when all the condition below are satisfied:
|
69
|
+
# - same element identifier.
|
70
|
+
# - difference of coordinates is the same.
|
71
|
+
# This method should be used after well-consideration.
|
72
|
+
# Arbitrary coordinates are not generally the same like Float instances.
|
73
|
+
# It is a good idea to use in test scripts.
|
74
|
+
def ==(other)
|
75
|
+
#pp self
|
76
|
+
#pp other
|
77
|
+
self.class.equal_in_delta?(self, other, 0.0)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Equivalence checking (instance method version) .
|
81
|
+
# Return true when all the condition below are satisfied:
|
82
|
+
# - same element identifier.
|
83
|
+
# - difference of coordinates is within tolerance.
|
84
|
+
def equal_in_delta?(other, tol = 0.0)
|
85
|
+
self.class.equal_in_delta?(self, other, tol)
|
86
|
+
end
|
87
|
+
|
88
|
+
#Return Vector3DInternal instance consist of coordinates between 0 and 1.
|
89
|
+
def internal_coordinates
|
90
|
+
result = @position.map{ |coord| coord - coord.floor }
|
91
|
+
return Vector3DInternal[ *result ]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Return Vector3DInternal instance consist of integers,
|
95
|
+
# by which self.internal_coordinates translate to self.position.
|
96
|
+
def translation_symmetry_operation
|
97
|
+
result = @position.map{ |coord| coord.floor }
|
98
|
+
return Vector3DInternal[ *result ]
|
99
|
+
end
|
100
|
+
|
101
|
+
# Overwrite position.
|
102
|
+
def set_position(position)
|
103
|
+
#pp position
|
104
|
+
#pp position.class
|
105
|
+
raise TypeError, "#{position.class}" if position.class == Vector3D
|
106
|
+
@position = position.to_v3di
|
107
|
+
end
|
108
|
+
|
109
|
+
# Translate atom position (destructive).
|
110
|
+
# Argument 'vec' should be given as internal vector,
|
111
|
+
# which is an Array or Vector3DInternal instance but Vector3D instance.
|
112
|
+
def translate!(vec)
|
113
|
+
raise TypeError if vec.class == Vector3D
|
114
|
+
raise TypeError if vec.size != 3
|
115
|
+
self.set_position(@position + Vector3DInternal[ *vec ])
|
116
|
+
end
|
117
|
+
|
118
|
+
# Translate atom position (nondestructive).
|
119
|
+
# Argument 'vec' should be given as internal vector,
|
120
|
+
# which is an Array or Vector3DInternal instance but Vector3D instance.
|
121
|
+
def translate(vec)
|
122
|
+
tmp = Marshal.load(Marshal.dump(self))
|
123
|
+
tmp.translate!(vec)
|
124
|
+
return tmp
|
125
|
+
end
|
128
126
|
|
129
127
|
end
|
130
128
|
|