Class: VaspUtils::Potcar::Concatenater
- Inherits:
-
Object
- Object
- VaspUtils::Potcar::Concatenater
- Defined in:
- lib/vasputils/potcar/concatenater.rb
Defined Under Namespace
Classes: NoPotcarError
Instance Method Summary collapse
-
#dump(elements, io = nil) ⇒ Object
Concatenate POTCARs.
-
#initialize(potcar_path, elem_potcar) ⇒ Concatenater
constructor
‘potcar_path’ indicates a storage directory of POTCARs.
Constructor Details
#initialize(potcar_path, elem_potcar) ⇒ Concatenater
‘potcar_path’ indicates a storage directory of POTCARs. ‘elem_potcar’ indicates a correspondence between element symbol and prior POTCAR as Hash.
15 16 17 18 |
# File 'lib/vasputils/potcar/concatenater.rb', line 15 def initialize(potcar_path, elem_potcar) @potcar_path = potcar_path @elem_potcar = elem_potcar end |
Instance Method Details
#dump(elements, io = nil) ⇒ Object
Concatenate POTCARs. Write to io if defined Return string if io is nil.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vasputils/potcar/concatenater.rb', line 23 def dump(elements, io = nil) result = elements.map { |elem| raise NoPotcarError unless @elem_potcar.include? elem filename = @potcar_path + "/" + @elem_potcar[elem] + "/POTCAR" File.read filename }.join("") if io # is defined io.print result else return result end end |