AtomSet.C 16.16 KiB
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// 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/>.
////////////////////////////////////////////////////////////////////////////////
// AtomSet.C
////////////////////////////////////////////////////////////////////////////////
// $Id: AtomSet.C,v 1.29 2010-04-16 21:40:50 fgygi Exp $
#include "AtomSet.h"
#include "Species.h"
#include "NameOf.h"
#include "sampling.h"
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
////////////////////////////////////////////////////////////////////////////////
AtomSet::~AtomSet(void)
  for ( int is = 0; is < species_list.size(); is++ )
    for ( int ia = 0; ia < atom_list[is].size(); ia++ )
      delete atom_list[is][ia];
    delete species_list[is];
////////////////////////////////////////////////////////////////////////////////
bool AtomSet::addSpecies(Species* sp, string name)
  const double rcps = 1.5;
  sp->initialize(rcps);
  Species *s = findSpecies(name);
  if ( s != 0 )
    // species is already defined: substitute with new definition
    if ( ctxt_.onpe0() )
      cout << " AtomSet::addSpecies: species " << name
           << " is already defined" << endl;
      cout << " AtomSet::addSpecies: redefining species" << endl;
    // Check if s and sp are compatible: zval must be equal
    if ( s->zval() != sp->zval() )
      cout << " AtomSet::addSpecies: species do not have the same"
           << " number of valence electrons. Cannot redefine species" << endl;
      return false;
    int is = isp_[s->name()];
    species_list[is] = sp;
    delete s;
  else