Commit 825c64b3 by Francois Gygi

redesign of SampleReader for nspin=2

git-svn-id: http://qboxcode.org/svn/qb/trunk@1275 cba15fb0-1239-40c8-b417-11db7ca47a34
parent 2a50e049
......@@ -15,9 +15,6 @@
// AtomSetHandler.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: AtomSetHandler.C,v 1.13 2008-09-08 15:56:18 fgygi Exp $
#if USE_XERCES
#include "AtomSetHandler.h"
#include "AtomSet.h"
......@@ -104,20 +101,6 @@ void AtomSetHandler::endElement(const XMLCh* const uri,
istringstream stst(content);
if ( locname == "unit_cell")
{
event_type event = unit_cell;
as_.context().ibcast_send(1,1,(int*)&event,1);
// notify listening nodes
double buf[9];
buf[0] = as_.cell().a(0).x;
buf[1] = as_.cell().a(0).y;
buf[2] = as_.cell().a(0).z;
buf[3] = as_.cell().a(1).x;
buf[4] = as_.cell().a(1).y;
buf[5] = as_.cell().a(1).z;
buf[6] = as_.cell().a(2).x;
buf[7] = as_.cell().a(2).y;
buf[8] = as_.cell().a(2).z;
as_.context().dbcast_send(9,1,buf,9);
}
else if ( locname == "atom")
{
......@@ -143,21 +126,6 @@ void AtomSetHandler::endElement(const XMLCh* const uri,
throw;
}
// notify listening nodes and broadcast atom info
event_type event = atom;
as_.context().ibcast_send(1,1,(int*)&event,1);
as_.context().string_bcast(current_atom_name,0);
as_.context().string_bcast(current_atom_species,0);
double buf[3];
buf[0] = current_atom_position.x;
buf[1] = current_atom_position.y;
buf[2] = current_atom_position.z;
as_.context().dbcast_send(3,1,buf,3);
buf[0] = current_atom_velocity.x;
buf[1] = current_atom_velocity.y;
buf[2] = current_atom_velocity.z;
as_.context().dbcast_send(3,1,buf,3);
}
else if ( locname == "position" )
{
......@@ -193,7 +161,7 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri,
}
// delegate to SpeciesHandler
current_species = new Species(as_.context(),current_species_name);
current_species = new Species(current_species_name);
return new SpeciesHandler(*current_species);
}
else
......@@ -211,7 +179,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
// cout << " AtomSetHandler::endSubHandler " << locname << endl;
if ( locname == "species" )
{
SpeciesReader sp_reader(current_species->context());
SpeciesReader sp_reader;
// check if only the uri was provided
if ( current_species->uri() != "" )
......@@ -219,22 +187,9 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
// href was found in species definition
// attempt to read the species from that uri
try
{
sp_reader.readSpecies(*current_species,current_species->uri());
}
catch ( const SpeciesReaderException& e )
{
cout << " SpeciesReaderException caught in AtomSetHandler" << endl;
}
sp_reader.uri_to_species(current_species->uri(),*current_species);
}
// notify listening nodes and broadcast species info
event_type event = species;
as_.context().ibcast_send(1,1,(int*)&event,1);
as_.context().string_bcast(current_species_name,0);
sp_reader.bcastSpecies(*current_species);
// cout << "AtomSetHandler::endSubHandler: adding Species:"
// << current_species_name << endl;
try
......@@ -250,5 +205,3 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
}
delete last;
}
#endif
......@@ -139,7 +139,7 @@ CXXFLAGS += -DTARGET='"$(TARGET)"'
testBasisMapping: testBasisMapping.o BasisMapping.o Basis.o \
Context.o UnitCell.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testSpecies: testSpecies.o Species.o sinft.o spline.o Context.o \
testSpecies: testSpecies.o Species.o sinft.o spline.o \
SpeciesReader.o StructuredDocumentHandler.o SpeciesHandler.o
$(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS)
testXCFunctional: testXCFunctional.o LDAFunctional.o PBEFunctional.o
......@@ -293,20 +293,6 @@ BOSampleStepper.o: SampleStepper.h Timer.h EnergyFunctional.h ChargeDensity.h
BOSampleStepper.o: Context.h StructureFactor.h Sample.h AtomSet.h Atom.h
BOSampleStepper.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
BOSampleStepper.o: Wavefunction.h Control.h
BOSampleStepper-merge.o: BOSampleStepper.h SampleStepper.h Timer.h
BOSampleStepper-merge.o: EnergyFunctional.h ChargeDensity.h Context.h
BOSampleStepper-merge.o: StructureFactor.h Sample.h AtomSet.h Atom.h
BOSampleStepper-merge.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
BOSampleStepper-merge.o: Wavefunction.h Control.h SlaterDet.h Basis.h
BOSampleStepper-merge.o: Matrix.h WavefunctionStepper.h
BOSampleStepper-merge.o: SDWavefunctionStepper.h PSDWavefunctionStepper.h
BOSampleStepper-merge.o: PSDAWavefunctionStepper.h JDWavefunctionStepper.h
BOSampleStepper-merge.o: SDIonicStepper.h IonicStepper.h Species.h
BOSampleStepper-merge.o: SDAIonicStepper.h LineMinimizer.h CGIonicStepper.h
BOSampleStepper-merge.o: CGOptimizer.h MDIonicStepper.h BMDIonicStepper.h
BOSampleStepper-merge.o: SDCellStepper.h CellStepper.h CGCellStepper.h
BOSampleStepper-merge.o: Preconditioner.h AndersonMixer.h MLWFTransform.h
BOSampleStepper-merge.o: BasisMapping.h
BtHF.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
BtHF.o: ConstraintSet.h ExtForceSet.h Wavefunction.h Control.h
CellDyn.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
......@@ -468,9 +454,6 @@ LineMinimizer.o: LineMinimizer.h
ListAtomsCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h
ListAtomsCmd.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
ListAtomsCmd.o: Wavefunction.h Control.h
ListConstraintsCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h
ListConstraintsCmd.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
ListConstraintsCmd.o: Wavefunction.h Control.h
ListSpeciesCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h
ListSpeciesCmd.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
ListSpeciesCmd.o: Wavefunction.h Control.h
......@@ -592,9 +575,8 @@ SampleHandler.o: StrX.h
SampleHandler.o: StructureHandler.h
SampleReader.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
SampleReader.o: ConstraintSet.h ExtForceSet.h Wavefunction.h Control.h
SampleReader.o: SampleReader.h SpeciesReader.h Species.h Basis.h
SampleReader.o: FourierTransform.h Timer.h SlaterDet.h Matrix.h
SampleReader.o: XMLGFPreprocessor.h SampleHandler.h StructureHandler.h
SampleReader.o: SampleReader.h XMLGFPreprocessor.h Matrix.h Timer.h
SampleReader.o: SampleHandler.h StructureHandler.h
SampleReader.o: StructuredDocumentHandler.h StrX.h
SampleStepper.o: SampleStepper.h Timer.h Sample.h AtomSet.h Context.h Atom.h
SampleStepper.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
......@@ -609,8 +591,6 @@ SaveCmd.o: D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h Wavefunction.h
SaveCmd.o: Control.h SampleWriter.h isodate.h release.h
SaveCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h D3vector.h
SaveCmd.o: UnitCell.h ConstraintSet.h ExtForceSet.h Wavefunction.h Control.h
ScfTol.o: Sample.h AtomSet.h Context.h Atom.h D3vector.h UnitCell.h
ScfTol.o: ConstraintSet.h ExtForceSet.h Wavefunction.h Control.h
SDAIonicStepper.o: SDAIonicStepper.h IonicStepper.h Sample.h AtomSet.h
SDAIonicStepper.o: Context.h Atom.h D3vector.h UnitCell.h ConstraintSet.h
SDAIonicStepper.o: ExtForceSet.h Wavefunction.h Control.h Species.h
......@@ -643,21 +623,17 @@ SlaterDet.o: SlaterDet.h Context.h Basis.h D3vector.h UnitCell.h Matrix.h
SlaterDet.o: Timer.h FourierTransform.h blas.h Base64Transcoder.h
SlaterDet.o: SharedFilePtr.h
SlaterDet.o: Context.h Basis.h D3vector.h UnitCell.h Matrix.h Timer.h
Species.o: Species.h Context.h spline.h sinft.h
Species.o: Species.h spline.h sinft.h
SpeciesCmd.o: SpeciesCmd.h UserInterface.h Sample.h AtomSet.h Context.h
SpeciesCmd.o: Atom.h D3vector.h UnitCell.h ConstraintSet.h ExtForceSet.h
SpeciesCmd.o: Wavefunction.h Control.h SpeciesReader.h Species.h
SpeciesCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h D3vector.h
SpeciesCmd.o: UnitCell.h ConstraintSet.h ExtForceSet.h Wavefunction.h
SpeciesCmd.o: Control.h
Species.o: Context.h
SpeciesHandler.o: SpeciesHandler.h StructureHandler.h Species.h Context.h
SpeciesHandler.o: StrX.h
SpeciesHandler.o: SpeciesHandler.h StructureHandler.h Species.h StrX.h
SpeciesHandler.o: StructureHandler.h
SpeciesReader.o: Species.h Context.h SpeciesReader.h
SpeciesReader.o: StructuredDocumentHandler.h StrX.h StructureHandler.h
SpeciesReader.o: SpeciesHandler.h
SpeciesReader.o: Context.h
SpeciesReader.o: Species.h SpeciesReader.h StructuredDocumentHandler.h StrX.h
SpeciesReader.o: StructureHandler.h SpeciesHandler.h
spline.o: spline.h
StatusCmd.o: UserInterface.h Sample.h AtomSet.h Context.h Atom.h D3vector.h
StatusCmd.o: UnitCell.h ConstraintSet.h ExtForceSet.h Wavefunction.h
......@@ -690,17 +666,16 @@ testFourierTransform.o: Context.h Basis.h D3vector.h UnitCell.h
testFourierTransform.o: FourierTransform.h Timer.h
testjacobi.o: Timer.h Context.h Matrix.h jacobi.h
testjade.o: Timer.h Context.h Matrix.h jade.h
test_lapiv.o: Context.h Matrix.h
testLDAFunctional.o: LDAFunctional.h XCFunctional.h
testLineMinimizer.o: LineMinimizer.h
testMatrix.o: Timer.h Context.h Matrix.h
testPParse.o: StrX.h
testSample.o: Context.h SlaterDet.h Basis.h D3vector.h UnitCell.h Matrix.h
testSample.o: Timer.h Sample.h AtomSet.h Atom.h ConstraintSet.h ExtForceSet.h
testSample.o: Wavefunction.h Control.h
test_sinft.o: sinft.h readTSC.h
testSlaterDet.o: Context.h SlaterDet.h Basis.h D3vector.h UnitCell.h Matrix.h
testSlaterDet.o: Timer.h FourierTransform.h
testSpecies.o: Species.h Context.h SpeciesReader.h
testSpecies.o: Species.h SpeciesReader.h
testUnitCell.o: UnitCell.h D3vector.h
testWavefunction.o: Context.h Wavefunction.h D3vector.h UnitCell.h
testWavefunction.o: SlaterDet.h Basis.h Matrix.h Timer.h
......@@ -723,8 +698,6 @@ TorsionConstraint.o: Constraint.h D3vector.h
UnitCell.o: UnitCell.h D3vector.h
UnitCell.o: D3vector.h
UserInterface.o: UserInterface.h qbox_xmlns.h
VWNFunctional.o: VWNFunctional.h XCFunctional.h
VWNFunctional.o: XCFunctional.h
Wavefunction.o: Wavefunction.h D3vector.h UnitCell.h SlaterDet.h Context.h
Wavefunction.o: Basis.h Matrix.h Timer.h jacobi.h SharedFilePtr.h
Wavefunction.o: D3vector.h UnitCell.h
......
......@@ -15,9 +15,6 @@
// SampleHandler.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SampleHandler.C,v 1.11 2008-09-08 15:56:19 fgygi Exp $
#if USE_XERCES
#include "SampleHandler.h"
#include "Sample.h"
......@@ -30,13 +27,8 @@ using namespace xercesc;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
SampleHandler::SampleHandler(Sample& s, DoubleMatrix& gfdata,
int& nx, int& ny, int& nz,
vector<vector<vector<double> > > &dmat,
Wavefunction& wfvtmp) :
s_(s), gfdata_(gfdata), nx_(nx), ny_(ny), nz_(nz),
dmat_(dmat), read_wf(false), read_wfv(false),
wfvtmp_(wfvtmp) {}
SampleHandler::SampleHandler(Sample& s, DoubleMatrix& gfdata) :
s_(s), gfdata_(gfdata) {}
////////////////////////////////////////////////////////////////////////////////
SampleHandler::~SampleHandler() {}
......@@ -53,8 +45,8 @@ void SampleHandler::startElement(const XMLCh* const uri,
void SampleHandler::endElement(const XMLCh* const uri,
const XMLCh* const localname, const XMLCh* const qname, string& content)
{
//istringstream stst(st);
string locname(XMLString::transcode(localname));
// istringstream stst(st);
// string locname(XMLString::transcode(localname));
// cout << " SampleHandler::endElement " << locname << endl;
}
......@@ -75,12 +67,13 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
else if ( qnm == "wavefunction" )
{
read_wf = true;
return new WavefunctionHandler(s_.wf,gfdata_,nx_,ny_,nz_,dmat_);
return new WavefunctionHandler(s_.wf,gfdata_);
}
else if ( qnm == "wavefunction_velocity" )
{
read_wfv = true;
return new WavefunctionHandler(wfvtmp_,gfdata_,nx_,ny_,nz_,dmat_);
s_.wfv = new Wavefunction(s_.ctxt_);
return new WavefunctionHandler(*s_.wfv,gfdata_);
}
else
{
......@@ -96,4 +89,3 @@ void SampleHandler::endSubHandler(const XMLCh* const uri,
// cout << " SampleHandler::endSubHandler " << StrX(qname) << endl;
delete subHandler;
}
#endif
......@@ -32,16 +32,11 @@ class SampleHandler : public StructureHandler
private:
Sample& s_;
std::vector<std::vector<std::vector<double> > > &dmat_;
DoubleMatrix& gfdata_;
Wavefunction& wfvtmp_;
public:
bool read_wf,read_wfv;
int& nx_;
int& ny_;
int& nz_;
// Start of the root element in the structure being handled
virtual void startElement(const XMLCh* const uri,const XMLCh* const localname,
......@@ -61,9 +56,7 @@ class SampleHandler : public StructureHandler
const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const subHandler);
SampleHandler(Sample& s, DoubleMatrix& gfdata, int& nx, int& ny, int& nz,
std::vector<std::vector<std::vector<double> > > &dmat,
Wavefunction& wfvtmp);
SampleHandler(Sample& s, DoubleMatrix& gfdata);
~SampleHandler();
};
#endif
......@@ -1321,6 +1321,9 @@ void SlaterDet::write(SharedFilePtr& sfp, string encoding, double weight,
vector<double> wftmpr(wftmpr_loc_size);
Base64Transcoder xcdr;
// do not write anything if nst==0
if ( nst() == 0 ) return;
#if USE_MPI
char* wbuf = 0;
size_t wbufsize = 0;
......
......@@ -15,7 +15,6 @@
// Species.C:
//
////////////////////////////////////////////////////////////////////////////////
// $Id: Species.C,v 1.16 2010-02-20 23:25:38 fgygi Exp $
#include "Species.h"
#include "spline.h"
......@@ -47,7 +46,7 @@ static double simpsn ( int n, double *t )
}
////////////////////////////////////////////////////////////////////////////////
Species::Species(const Context& ctxt, string name) : ctxt_(ctxt), name_(name),
Species::Species(string name) : name_(name),
zval_(-1), mass_(0.0), lmax_(-1), deltar_(0.0), atomic_number_(0),
llocal_(-1), nquad_(-1), rquad_(0.0),
rcps_(0.0), uri_(""), description_("undefined"), symbol_("Undef")
......@@ -67,7 +66,7 @@ bool Species::initialize(double rcpsval)
if (zval_ < 0) throw SpeciesInitException("zval_ < 0");
if (rcps_ < 0.0) throw SpeciesInitException("rcps_ < 0");
if (mass_ < 0.0) throw SpeciesInitException("mass_ < 0");
if (lmax_ < 0 || lmax_ > 3) throw SpeciesInitException("lmax_ <0 or lmax_ >3");
if (lmax_ < 0 || lmax_ > 3) throw SpeciesInitException("lmax_<0 or lmax_>3");
if (vps_.size() < lmax_+1) throw SpeciesInitException("vps_.size < lmax_+1");
......@@ -565,43 +564,50 @@ double Species::rhopsg( double g )
ostream& operator << ( ostream &os, Species &s )
{
s.print(os, false);
return os;
}
void Species::print(ostream &os, bool expanded_form)
{
// XML output of species
// If the uri is known, use href to refer to it
if ( s.uri() != "" )
// print in compact form if the uri is known
// and if expanded_form==false
if ( !expanded_form && uri() != "" )
{
os <<"<species name=\"" << s.name()
<< "\" href=\"" << s.uri() << "\"/>" << endl;
os <<"<species name=\"" << name()
<< "\" href=\"" << uri() << "\"/>" << endl;
}
else
{
os <<"<species name=\"" << s.name() << "\">" << endl;
os << "<description>" << s.description() << "</description>" << endl;
os << "<symbol>" << s.symbol() << "</symbol>" << endl;
os << "<atomic_number>" << s.atomic_number() << "</atomic_number>" << endl;
os << "<mass>" << s.mass() << "</mass>" << endl;
os <<"<species name=\"" << name() << "\">" << endl;
os << "<description>" << description() << "</description>" << endl;
os << "<symbol>" << symbol() << "</symbol>" << endl;
os << "<atomic_number>" << atomic_number() << "</atomic_number>" << endl;
os << "<mass>" << mass() << "</mass>" << endl;
os << "<norm_conserving_pseudopotential>" << endl;
os << "<valence_charge>" << s.zval() << "</valence_charge>" << endl;
os << "<lmax>" << s.lmax() << "</lmax>" << endl;
os << "<llocal>" << s.llocal() << "</llocal>" << endl;
os << "<nquad>" << s.nquad() << "</nquad>" << endl;
os << "<rquad>" << s.rquad() << "</rquad>" << endl;
os << "<mesh_spacing>" << s.deltar() << "</mesh_spacing>" << endl;
os << "<valence_charge>" << zval() << "</valence_charge>" << endl;
os << "<lmax>" << lmax() << "</lmax>" << endl;
os << "<llocal>" << llocal() << "</llocal>" << endl;
os << "<nquad>" << nquad() << "</nquad>" << endl;
os << "<rquad>" << rquad() << "</rquad>" << endl;
os << "<mesh_spacing>" << deltar() << "</mesh_spacing>" << endl;
os.setf(ios::fixed,ios::floatfield);
os << setprecision(6);
for ( int l = 0; l <= s.lmax(); l++ )
for ( int l = 0; l <= lmax(); l++ )
{
const int size = s.vps()[l].size();
const int size = vps()[l].size();
os << "<projector l=\"" << l << "\" size=\"" << size
<< "\">" << endl;
os << "<radial_potential>\n";
for ( int i = 0; i < size; i++ )
os << s.vps()[l][i] << "\n";
os << vps()[l][i] << "\n";
os << "</radial_potential>\n";
if ( l < s.phi().size() && s.phi()[l].size() == size )
if ( l < phi().size() && phi()[l].size() == size )
{
os << "<radial_function>\n";
for ( int i = 0; i < size; i++ )
os << s.phi()[l][i] << "\n";
os << phi()[l][i] << "\n";
os << "</radial_function>\n";
}
os << "</projector>" << endl;
......@@ -609,8 +615,6 @@ ostream& operator << ( ostream &os, Species &s )
os << "</norm_conserving_pseudopotential>" << endl;
os << "</species>" << endl;
}
return os;
}
void Species::info(ostream &os)
......@@ -626,7 +630,7 @@ void Species::info(ostream &os)
{
os <<"<species name=\"" << name() << "\">" << endl;
}
os << " <description>" << description() << "</description>" << endl;
os << " <description>" << description() << " </description>" << endl;
os << " <symbol>" << symbol() << "</symbol>" << endl;
os << " <atomic_number>" << atomic_number() << "</atomic_number>" << endl;
os << " <mass>" << mass() << "</mass>" << endl;
......
......@@ -15,7 +15,6 @@
// Species.h:
//
////////////////////////////////////////////////////////////////////////////////
// $Id: Species.h,v 1.9 2008-09-08 15:56:19 fgygi Exp $
#ifndef SPECIES_H
#define SPECIES_H
......@@ -24,24 +23,23 @@
#include <string>
#include <vector>
#include <cmath>
#include "Context.h"
class Species
{
private:
const Context& ctxt_;
int nlm_; // number of non-local projectors:
int ndft_;
std::vector<std::vector<double> > vps_spl_, phi_spl_;
std::vector<double> gspl_, vlocg_, vlocg_spl;
std::vector<std::vector<double> > vnlg_, vnlg_spl;
std::vector<double> wsg_; // wsg_[l] Kleinman-Bylander weight 1/<phi|delta_V|phi>
std::vector<double> wsg_; // wsg_[l] Kleinman-Bylander weight
// 1/<phi|delta_V|phi>
std::vector<double> rps_; // radial linear mesh (same for all l)
std::string name_; // name used to refer to species in current application
std::string name_; // name used in current application
std::string uri_; // uri of the resource defining the pseudopotential
std::string symbol_;
......@@ -61,9 +59,8 @@ class Species
public:
Species(const Context& ctxt, std::string name);
Species(std::string name);
const Context& context(void) const { return ctxt_; }
const std::string& name(void) const { return name_; }
const std::string& symbol(void) const { return symbol_; }
const std::string& description(void) const { return description_; }
......@@ -101,6 +98,7 @@ class Species
bool initialize(double rcps);
void info(std::ostream& os);
void print(std::ostream& os, bool expanded_form);
friend class SpeciesReader;
friend class SpeciesHandler;
......
......@@ -15,7 +15,6 @@
// SpeciesCmd.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SpeciesCmd.C,v 1.12 2008-09-08 15:56:19 fgygi Exp $
#include "SpeciesCmd.h"
#include "SpeciesReader.h"
......@@ -35,28 +34,20 @@ int SpeciesCmd::action(int argc, char **argv)
}
if ( ui->onpe0() )
{
cout << " SpeciesCmd: defining species " << argv[1]
<< " as " << argv[2] << endl;
}
SpeciesReader sp_reader(s->ctxt_);
Species* sp = new Species(s->ctxt_,argv[1]);
string xmlstr;
SpeciesReader sp_reader;
if ( ui->onpe0() )
sp_reader.uri_to_string(argv[2], argv[1], xmlstr);
try
{
sp_reader.readSpecies(*sp,argv[2]);
sp_reader.bcastSpecies(*sp);
s->atoms.addSpecies(sp,argv[1]);
}
catch ( const SpeciesReaderException& e )
{
cout << " SpeciesReaderException caught in SpeciesCmd" << endl;
cout << " SpeciesReaderException: cannot define Species" << endl;
}
catch (...)
{
cout << " SpeciesCmd: cannot define Species" << endl;
}
s->ctxt_.string_bcast(xmlstr,0);
Species* sp = new Species("argv[1]");
sp_reader.string_to_species(xmlstr,*sp);
s->atoms.addSpecies(sp,argv[1]);
return 0;
}
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008 The Regents of the University of California
// Copyright (c) 2008-2012 The Regents of the University of California
//
// This file is part of Qbox
//
......@@ -15,9 +15,6 @@
// SpeciesHandler.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SpeciesHandler.C,v 1.6 2008-09-08 15:56:19 fgygi Exp $
#if USE_XERCES
#include "SpeciesHandler.h"
#include "Species.h"
......@@ -29,8 +26,7 @@ using namespace xercesc;
using namespace std;
////////////////////////////////////////////////////////////////////////////////
SpeciesHandler::SpeciesHandler(Species& sp) :
sp_(sp) {}
SpeciesHandler::SpeciesHandler(Species& sp) : sp_(sp) {}
////////////////////////////////////////////////////////////////////////////////
SpeciesHandler::~SpeciesHandler() {}
......@@ -59,9 +55,6 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
else if ( attrname == "href" )
{
current_href = StrX(attributes.getValue(index)).localForm();
cout << " SpeciesHandler: found href in species definition" << endl
<< " name=" << current_name << " href=" << current_href
<< endl;
sp_.uri_ = current_href;
}
}
......@@ -180,5 +173,3 @@ void SpeciesHandler::endSubHandler(const XMLCh* const uri,
// if any StructureHandler was created by startSubHandler, delete it
// delete subHandler;
}
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008 The Regents of the University of California
// Copyright (c) 2008-2012 The Regents of the University of California
//
// This file is part of Qbox
//
......@@ -15,29 +15,28 @@
// SpeciesReader.h:
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SpeciesReader.h,v 1.7 2008-09-08 15:56:19 fgygi Exp $
#ifndef SPECIESREADER_H
#define SPECIESREADER_H
#include <string>
#include "Context.h"
class SpeciesReader
{
private:
const Context& ctxt_;
std::string uri_; // uri from which Species is read
public:
SpeciesReader(const Context& ctxt);
void readSpecies(Species& sp, const std::string uri);
void bcastSpecies(Species& sp);
};
SpeciesReader(void);
class SpeciesReaderException {};
// initialize a Species object using a species URI
void uri_to_species(const std::string uri, Species& sp);
// initialize a string containing an XML <species> element using a species URI
void uri_to_string(const std::string uri, const std::string name,
std::string& xmlstr);
// initialize a Species object using a string containing a <species> element
void string_to_species(const std::string xmlstr, Species& sp);
};
#endif
......@@ -290,6 +290,17 @@ void Wavefunction::set_deltaspin(int deltaspin)
{
if ( deltaspin == deltaspin_ ) return;
// check if value of deltaspin would result in nst[1] < 0
// nst_[1] = nel_ / 2 - deltaspin_ + nempty_;
if ( nel_ / 2 - deltaspin + nempty_ < 0 )
{
if ( ctxt_.onpe0() )
{
cout << " Wavefunction::set_deltaspin: nel+nempty too small" << endl;
cout << " Wavefunction::set_deltaspin: cannot set deltaspin" << endl;
return;
}
}
deallocate();
deltaspin_ = deltaspin;
compute_nst();
......
......@@ -116,6 +116,8 @@ class Wavefunction
void print(std::ostream& os, std::string encoding, std::string tag) const;
void write(SharedFilePtr& fh, std::string encoding, std::string tag) const;
void info(std::ostream& os, std::string tag) const;
friend class WavefunctionHandler;
};
std::ostream& operator << ( std::ostream& os, const Wavefunction& wf );
#endif
......@@ -15,7 +15,6 @@
// WavefunctionHandler.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: WavefunctionHandler.h,v 1.13 2008-09-08 15:56:19 fgygi Exp $
#ifndef WavefunctionHANDLER_H
#define WavefunctionHANDLER_H
......@@ -36,15 +35,11 @@ class WavefunctionHandler : public StructureHandler
UnitCell uc;
UnitCell ruc;
double ecut;
// dmat[ispin][ikp][i]
std::vector<std::vector<std::vector<double> > > &dmat_;
int& nx_;
int& ny_;
int& nz_;
int nx_, ny_, nz_;
int current_gf_nx,current_gf_ny,current_gf_nz;
std::string current_gf_encoding;
int current_ispin,current_ikp,current_n,current_igf;
std::vector<double> dmat_tmp;
int current_ispin,current_ikp;
std::vector<double> dmat_;
double current_kx, current_ky, current_kz, current_weight;
int current_size;
int read_from_gfdata;
......@@ -73,9 +68,7 @@ class WavefunctionHandler : public StructureHandler
const XMLCh* const localname, const XMLCh* const qname,
const StructureHandler* const subHandler);
WavefunctionHandler(Wavefunction& wf, DoubleMatrix& gfdata,
int& nx, int& ny, int& nz,
std::vector<std::vector<std::vector<double> > > &dmat);
WavefunctionHandler(Wavefunction& wf, DoubleMatrix& gfdata);
~WavefunctionHandler();
};
#endif
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008 The Regents of the University of California
// Copyright (c) 2008-2012 The Regents of the University of California
//
// This file is part of Qbox
//
......@@ -15,7 +15,6 @@
// XMLGFPreprocessor.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: XMLGFPreprocessor.C,v 1.17 2009-11-30 02:47:20 fgygi Exp $
#include <cassert>
#include <iostream>
......@@ -39,19 +38,27 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////
//
// XMLGFPreprocessor class
// Used to preprocess <grid_function> elements in an XML document
// Input: filename, DoubleMatrix& gfdata, string xmlcontent
// The preprocessor reads the file in parallel, processes all <grid_function>
// elements and stores the values of the grid_functions in the matrix gfdata
// which has dimensions (ngf,maxgridsize), where ngf is the total number of
//
// Used to preprocess a sample document.
// The contents of all <grid_function> elements is removed from the XML
// document and stored in the distributed matrix gfdata.
// All <species> elements are expanded from their url or file name and
// inserted in the xmlcontent string.
//
// Input: filename or uri, DoubleMatrix& gfdata, string xmlcontent
// If the uri is a file name, the preprocessor reads the file in parallel,
// then processes all <grid_function> elements and stores the values of
// the grid_functions in the matrix gfdata which has dimensions
// (ngf,maxgridsize), where ngf is the total number of
// <grid_function> elements found in the file, and maxgridsize is the size of
// the largest grid_function.
// On return, the string xmlcontent contains (on task 0) the XML file
// with <grid_function> elements reduced to empty strings.
// On return, the string xmlcontent contains (on all tasks) the XML document
// with <grid_function> elements reduced to empty strings and <species>
// elements expanded to include all species information.
//
////////////////////////////////////////////////////////////////////////////////
void XMLGFPreprocessor::process(const char* const filename,
DoubleMatrix& gfdata, string& xmlcontent)
void XMLGFPreprocessor::process(const char* const uri,
DoubleMatrix& gfdata, string& xmlcontent, bool serial)
{
cout.precision(4);
......@@ -70,87 +77,109 @@ void XMLGFPreprocessor::process(const char* const filename,
ttm.start();