AtomSet.h 2.6 KB
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
// AtomSet.h
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
6
// $Id: AtomSet.h,v 1.20 2008-03-21 00:26:19 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12

#ifndef ATOMSET_H
#define ATOMSET_H

#include "Context.h"
#include "Atom.h"
13
#include "UnitCell.h"
14 15
#include <vector>
#include <string>
Francois Gygi committed
16 17 18 19
#include <list>
#include <map>
#include <string>

20 21
class Species;

Francois Gygi committed
22 23 24
class AtomSet
{
  private:
25

Francois Gygi committed
26
  const Context& ctxt_;
27

Francois Gygi committed
28
  int nel_;
29 30 31 32 33
  std::map<std::string,int> na_;  // na_[sp_name]: number of at. of spec. sp_name
  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
34

Francois Gygi committed
35
  UnitCell cell_;
36

Francois Gygi committed
37
  public:
38

Francois Gygi committed
39
  AtomSet(const Context& ctxt) : ctxt_(ctxt), nel_(0) {}
Francois Gygi committed
40

41 42
  std::vector<std::vector<Atom *> > atom_list; // atom_list[is][ia]
  std::vector<Species *> species_list;    // species_list[is]
Francois Gygi committed
43 44 45

  const Context& context(void) const { return ctxt_; }
  bool addAtom(Atom *a);
46 47 48
  bool delAtom(std::string name);
  bool addSpecies(Species *sp, std::string name);
  bool delSpecies(std::string name);
Francois Gygi committed
49
  bool reset(void); // remove all atoms and species
50 51
  Atom *findAtom(std::string name) const;
  Species *findSpecies(std::string name) const;
Francois Gygi committed
52 53
  void listAtoms(void) const;
  void listSpecies(void) const;
54
  int na(const std::string& spname) const;  // number of atoms of species spname
Francois Gygi committed
55
  int na(int is) const;         // number of atoms of species is
56 57 58
  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
59 60
  int nel(void) const { return nel_; };
  int nsp(void) const { return species_list.size(); }
61 62 63 64
  void get_positions(std::vector<std::vector<double> >& tau) const;
  void set_positions(const std::vector<std::vector<double> >& tau);
  void get_velocities(std::vector<std::vector<double> >& vel) const;
  void set_velocities(const std::vector<std::vector<double> >& vel);
Francois Gygi committed
65 66 67 68 69 70
  const UnitCell& cell(void) const { return cell_; }
  void set_cell(const UnitCell& cell) { cell_ = cell; }
  void set_cell(const D3vector& a, const D3vector& b, const D3vector& c)
  {
    cell_.set(a,b,c);
  }
71
  void sync(void);
72
  void reset_velocities(void);
73
  D3vector vcm(void) const;
Francois Gygi committed
74
  D3vector dipole(void) const;
75
  void reset_vcm(void);
Francois Gygi committed
76
  void fold_in_ws(void);
Francois Gygi committed
77
  int size(void) const;
78 79
 };
std::ostream& operator << ( std::ostream &os, const AtomSet &as );
Francois Gygi committed
80
#endif