Class: AsciiChem::Model::Crystal
- Defined in:
- lib/asciichem/model/crystal.rb
Overview
A crystal structure: unit cell parameters + space group + asymmetric-unit atoms with fractional coordinates.
Syntax:
crystal[NaCl](a=5.64,b=5.64,c=5.64,alpha=90,beta=90,gamma=90,sg=Fm-3m){
Na@f(0,0,0)
Cl@f(0.5,0.5,0.5)
}
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#atoms ⇒ Object
Returns the value of attribute atoms.
-
#b ⇒ Object
Returns the value of attribute b.
-
#beta ⇒ Object
Returns the value of attribute beta.
-
#c ⇒ Object
Returns the value of attribute c.
-
#gamma ⇒ Object
Returns the value of attribute gamma.
-
#name ⇒ Object
Returns the value of attribute name.
-
#spacegroup ⇒ Object
Returns the value of attribute spacegroup.
Instance Method Summary collapse
- #children ⇒ Object
- #diagnostic_label ⇒ Object
-
#initialize(name: nil, a: nil, b: nil, c: nil, alpha: nil, beta: nil, gamma: nil, spacegroup: nil, atoms: []) ⇒ Crystal
constructor
A new instance of Crystal.
- #to_s ⇒ Object
- #value_attributes ⇒ Object
Methods inherited from Node
#==, #accept, #hash, short_name, #to_cml, #to_html, #to_latex, #to_mathml, #to_svg, #to_text
Constructor Details
#initialize(name: nil, a: nil, b: nil, c: nil, alpha: nil, beta: nil, gamma: nil, spacegroup: nil, atoms: []) ⇒ Crystal
Returns a new instance of Crystal.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/asciichem/model/crystal.rb', line 17 def initialize(name: nil, a: nil, b: nil, c: nil, alpha: nil, beta: nil, gamma: nil, spacegroup: nil, atoms: []) @name = name @a = a @b = b @c = c @alpha = alpha @beta = beta @gamma = gamma @spacegroup = spacegroup @atoms = atoms end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def a @a end |
#alpha ⇒ Object
Returns the value of attribute alpha.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def alpha @alpha end |
#atoms ⇒ Object
Returns the value of attribute atoms.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def atoms @atoms end |
#b ⇒ Object
Returns the value of attribute b.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def b @b end |
#beta ⇒ Object
Returns the value of attribute beta.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def beta @beta end |
#c ⇒ Object
Returns the value of attribute c.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def c @c end |
#gamma ⇒ Object
Returns the value of attribute gamma.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def gamma @gamma end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def name @name end |
#spacegroup ⇒ Object
Returns the value of attribute spacegroup.
14 15 16 |
# File 'lib/asciichem/model/crystal.rb', line 14 def spacegroup @spacegroup end |
Instance Method Details
#children ⇒ Object
37 38 39 |
# File 'lib/asciichem/model/crystal.rb', line 37 def children atoms end |
#diagnostic_label ⇒ Object
41 42 43 |
# File 'lib/asciichem/model/crystal.rb', line 41 def diagnostic_label "Crystal(#{name || 'unnamed'})" end |
#to_s ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/asciichem/model/crystal.rb', line 45 def to_s params = [] params << "a=#{a}" if a params << "b=#{b}" if b params << "c=#{c}" if c params << "alpha=#{alpha}" if alpha params << "beta=#{beta}" if beta params << "gamma=#{gamma}" if gamma params << "sg=#{spacegroup}" if spacegroup "crystal[#{name}](#{params.join(',')}){#{atoms.map(&:to_s).join(' ')}}" end |
#value_attributes ⇒ Object
31 32 33 34 35 |
# File 'lib/asciichem/model/crystal.rb', line 31 def value_attributes { name: name, a: a, b: b, c: c, alpha: alpha, beta: beta, gamma: gamma, spacegroup: spacegroup, atoms: atoms } end |