AtomSet.h 3.38 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17 18 19 20 21 22 23
// AtomSet.h
//
////////////////////////////////////////////////////////////////////////////////

#ifndef ATOMSET_H
#define ATOMSET_H

#include "Context.h"
#include "Atom.h"
24
#include "UnitCell.h"
25
#include "D3tensor.h"
26 27
#include <vector>
#include <string>
Francois Gygi committed
28 29 30
#include <list>
#include <map>

31 32
class Species;

Francois Gygi committed
33 34 35
class AtomSet
{
  private:
36

Francois Gygi committed
37
  const Context& ctxt_;
38

Francois Gygi committed
39
  int nel_;
Francois Gygi committed
40
  std::map<std::string,int> na_;  // na_[sp_name]: num. of at. of spec. sp_name
41 42 43 44
  std::map<std::string,int> isp_; // isp_[sp_name]: index of species sp_name
  std::map<std::string,int> is_; // is_[atom_name]: is index of atom atom_name
  std::map<std::string,int> ia_; // ia_[atom_name]: ia index of atom atom_name
  std::vector<std::string> spname; // spname[is]: name of species is
45

Francois Gygi committed
46
  UnitCell cell_;
47

Francois Gygi committed
48
  public:
49

Francois Gygi committed
50
  AtomSet(const Context& ctxt) : ctxt_(ctxt), nel_(0) {}
51
  ~AtomSet(void);
Francois Gygi committed
52

53 54
  std::vector<std::vector<Atom *> > atom_list; // atom_list[is][ia]
  std::vector<Species *> species_list;    // species_list[is]
Francois Gygi committed
55 56 57

  const Context& context(void) const { return ctxt_; }
  bool addAtom(Atom *a);
58 59 60
  bool delAtom(std::string name);
  bool addSpecies(Species *sp, std::string name);
  bool delSpecies(std::string name);
Francois Gygi committed
61
  bool reset(void); // remove all atoms and species
62 63
  Atom *findAtom(std::string name) const;
  Species *findSpecies(std::string name) const;
Francois Gygi committed
64 65
  void listAtoms(void) const;
  void listSpecies(void) const;
66
  int na(const std::string& spname) const;  // number of atoms of species spname
Francois Gygi committed
67
  int na(int is) const;         // number of atoms of species is
68 69 70
  int isp(const std::string& spname) const; // index of species spname
  int is(const std::string& atom_name) const;
  int ia(const std::string& atom_name) const;
Francois Gygi committed
71 72
  int nel(void) const { return nel_; };
  int nsp(void) const { return species_list.size(); }
73
  void get_positions(std::vector<std::vector<double> >& tau) const;
Francois Gygi committed
74
  void sync_positions(std::vector<std::vector<double> >& tau);
75
  void set_positions(std::vector<std::vector<double> >& tau);
76
  void get_velocities(std::vector<std::vector<double> >& vel) const;
Francois Gygi committed
77
  void sync_velocities(std::vector<std::vector<double> >& vel);
78
  void set_velocities(std::vector<std::vector<double> >& vel);
Francois Gygi committed
79 80
  const UnitCell& cell(void) const { return cell_; }
  void set_cell(const UnitCell& cell) { cell_ = cell; }
Francois Gygi committed
81 82 83
  void set_cell(const D3vector& a, const D3vector& b, const D3vector& c);
  void sync_cell(void);
  void sync_cell(UnitCell& cell);
84
  void reset_velocities(void);
85
  void rescale_velocities(double fac);
86
  void randomize_velocities(double temp);
87
  void randomize_positions(double amplitude);
88
  D3vector rcm(void) const;
89
  D3vector vcm(void) const;
Francois Gygi committed
90
  D3vector dipole(void) const;
91
  D3tensor quadrupole(void) const;
92
  void reset_vcm(void);
93
  void reset_rotation(void);
Francois Gygi committed
94
  void fold_in_ws(void);
Francois Gygi committed
95
  int size(void) const;
96 97
 };
std::ostream& operator << ( std::ostream &os, const AtomSet &as );
Francois Gygi committed
98
#endif