Commit 32e60b21 by Francois Gygi

Added unit_cell to AtomSet


git-svn-id: http://qboxcode.org/svn/qb/trunk@572 cba15fb0-1239-40c8-b417-11db7ca47a34
parent a2a31f0e
......@@ -3,7 +3,7 @@
// AtomSet.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: AtomSet.C,v 1.18 2007-12-15 00:56:20 fgygi Exp $
// $Id: AtomSet.C,v 1.19 2008-02-03 22:53:54 fgygi Exp $
#include "AtomSet.h"
#include "Species.h"
......@@ -447,6 +447,7 @@ ostream& operator << ( ostream &os, const AtomSet &as )
if ( as.context().onpe0() )
{
os << "<atomset>\n";
os << as.unit_cell;
for ( int is = 0; is < as.species_list.size(); is++ )
{
os << *as.species_list[is];
......
......@@ -3,13 +3,14 @@
// AtomSet.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: AtomSet.h,v 1.17 2007-10-19 16:24:03 fgygi Exp $
// $Id: AtomSet.h,v 1.18 2008-02-03 22:53:55 fgygi Exp $
#ifndef ATOMSET_H
#define ATOMSET_H
#include "Context.h"
#include "Atom.h"
#include "UnitCell.h"
#include <vector>
#include <string>
#include <list>
......@@ -33,6 +34,8 @@ class AtomSet
public:
UnitCell unit_cell;
AtomSet(const Context& ctxt) : ctxt_(ctxt), nel_(0) {}
std::vector<std::vector<Atom *> > atom_list; // atom_list[is][ia]
......
......@@ -3,7 +3,7 @@
// AtomSetHandler.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: AtomSetHandler.C,v 1.8 2008-01-13 23:04:46 fgygi Exp $
// $Id: AtomSetHandler.C,v 1.9 2008-02-03 22:53:54 fgygi Exp $
#if USE_XERCES
......@@ -37,7 +37,32 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
// consider only elements that are dealt with directly by AtomSetHandler
// i.e. "atom". The "species" element is delegated to a SpeciesHandler
if ( locname == "atom")
if ( locname == "unit_cell")
{
D3vector a,b,c;
unsigned int len = attributes.getLength();
for (unsigned int index = 0; index < len; index++)
{
string attrname(XMLString::transcode(attributes.getLocalName(index)));
string attrval(XMLString::transcode(attributes.getValue(index)));
istringstream stst(attrval);
if ( attrname == "a")
{
stst >> a;
}
else if ( attrname == "b" )
{
stst >> b;
}
else if ( attrname == "c" )
{
stst >> c;
}
}
as_.unit_cell.set(a,b,c);
}
else if ( locname == "atom")
{
// set default velocity to zero
current_atom_velocity = D3vector(0.0,0.0,0.0);
......@@ -65,7 +90,24 @@ void AtomSetHandler::endElement(const XMLCh* const uri,
string locname(XMLString::transcode(localname));
// cout << " AtomSetHandler::endElement " << locname << endl;
istringstream stst(content);
if ( locname == "atom")
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_.unit_cell.a(0).x;
buf[1] = as_.unit_cell.a(0).y;
buf[2] = as_.unit_cell.a(0).z;
buf[3] = as_.unit_cell.a(1).x;
buf[4] = as_.unit_cell.a(1).y;
buf[5] = as_.unit_cell.a(1).z;
buf[6] = as_.unit_cell.a(2).x;
buf[7] = as_.unit_cell.a(2).y;
buf[8] = as_.unit_cell.a(2).z;
as_.context().dbcast_send(9,1,buf,9);
}
else if ( locname == "atom")
{
// create an instance of Atom using the current values read so far
// add the Atom to the current AtomSet
......
......@@ -3,7 +3,7 @@
// BOSampleStepper.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: BOSampleStepper.C,v 1.34 2007-10-19 17:06:28 fgygi Exp $
// $Id: BOSampleStepper.C,v 1.35 2008-02-03 22:53:55 fgygi Exp $
#include "BOSampleStepper.h"
#include "EnergyFunctional.h"
......@@ -243,6 +243,8 @@ void BOSampleStepper::step(int niter)
// print positions, velocities and forces at time t0
if ( onpe0 )
{
cout << "<atomset>" << endl;
cout << atoms.unit_cell;
for ( int is = 0; is < atoms.atom_list.size(); is++ )
{
int i = 0;
......@@ -269,6 +271,7 @@ void BOSampleStepper::step(int niter)
i += 3;
}
}
cout << "</atomset>" << endl;
cout << " <econst> " << energy+ekin_ion << " </econst>\n";
cout << " <ekin_ion> " << ekin_ion << " </ekin_ion>\n";
cout << " <temp_ion> " << temp_ion << " </temp_ion>\n";
......
......@@ -3,7 +3,7 @@
// CPSampleStepper.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: CPSampleStepper.C,v 1.14 2007-10-31 04:54:14 fgygi Exp $
// $Id: CPSampleStepper.C,v 1.15 2008-02-03 22:53:55 fgygi Exp $
#include "CPSampleStepper.h"
#include "SlaterDet.h"
......@@ -178,6 +178,8 @@ void CPSampleStepper::step(int niter)
if ( onpe0 )
{
cout << "<atomset>" << endl;
cout << atoms.unit_cell;
for ( int is = 0; is < atoms.atom_list.size(); is++ )
{
int i = 0;
......@@ -204,6 +206,7 @@ void CPSampleStepper::step(int niter)
i += 3;
}
}
cout << "</atomset>" << endl;
}
#if 1
if ( s_.constraints.size() > 0 )
......
......@@ -3,7 +3,7 @@
// Cell.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: Cell.h,v 1.5 2007-10-19 16:24:04 fgygi Exp $
// $Id: Cell.h,v 1.6 2008-02-03 22:53:54 fgygi Exp $
#ifndef CELL_H
#define CELL_H
......@@ -32,10 +32,10 @@ class Cell : public Var
return 1;
}
D3vector a0(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector a1(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector a2(atof(argv[7]),atof(argv[8]),atof(argv[9]));
UnitCell cell(a0,a1,a2);
D3vector a(atof(argv[1]),atof(argv[2]),atof(argv[3]));
D3vector b(atof(argv[4]),atof(argv[5]),atof(argv[6]));
D3vector c(atof(argv[7]),atof(argv[8]),atof(argv[9]));
UnitCell cell(a,b,c);
if ( cell.volume() < 0.0 )
{
......@@ -51,11 +51,11 @@ class Cell : public Var
s->wfv->clear();
}
s->atoms.unit_cell.set(a,b,c);
if ( ui->onpe0() )
{
cout << " <unitcell>\n"
<< s->wf.cell()
<< " </unitcell>" << endl;
cout << s->atoms.unit_cell;
}
return 0;
}
......
......@@ -3,7 +3,7 @@
// SampleReader.C:
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SampleReader.C,v 1.22 2008-01-13 23:04:46 fgygi Exp $
// $Id: SampleReader.C,v 1.23 2008-02-03 22:53:55 fgygi Exp $
#include "Sample.h"
......@@ -230,6 +230,16 @@ void SampleReader::readSample (Sample& s, const string uri, bool serial)
ctxt_.ibcast_recv(1,1,(int*)&event,1,0,0);
if ( event == end )
done = true;
else if ( event == unit_cell )
{
// unit_cell
double buf[9];
ctxt_.dbcast_recv(9,1,buf,9,0,0);
D3vector a(buf[0],buf[1],buf[2]);
D3vector b(buf[3],buf[4],buf[5]);
D3vector c(buf[6],buf[7],buf[8]);
s.atoms.unit_cell = UnitCell(a,b,c);
}
else if ( event == species )
{
// Species
......@@ -571,6 +581,10 @@ void SampleReader::readSample (Sample& s, const string uri, bool serial)
}
}
// force consistency of unit cell
// copy wavefunction domain on atomset unit_cell
s.atoms.unit_cell = s.wf.cell();
// check if wavefunction_velocity element was read, if not, delete wfvtmp
if ( s.wfv != 0 )
{
......
......@@ -3,12 +3,12 @@
// SampleReader.h
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SampleReader.h,v 1.5 2007-10-19 17:37:06 fgygi Exp $
// $Id: SampleReader.h,v 1.6 2008-02-03 22:53:55 fgygi Exp $
#ifndef SAMPLEREADER_H
#define SAMPLEREADER_H
enum event_type { species, atom, wavefunction, wavefunction_velocity,
enum event_type { unit_cell, species, atom, wavefunction, wavefunction_velocity,
slater_determinant, end, invalid };
class Context;
......
......@@ -3,7 +3,7 @@
// UnitCell.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: UnitCell.C,v 1.14 2007-10-31 05:08:30 fgygi Exp $
// $Id: UnitCell.C,v 1.15 2008-02-03 22:53:55 fgygi Exp $
#include "UnitCell.h"
#include <iostream>
......@@ -242,15 +242,16 @@ void UnitCell::print(ostream& os) const
{
os.setf(ios::fixed,ios::floatfield);
os << setprecision(8);
os << " <a> " << setw(12) << a_[0].x << " "
os << "<unit_cell " << endl;
os << " a=\"" << setw(12) << a_[0].x << " "
<< setw(12) << a_[0].y << " "
<< setw(12) << a_[0].z << " </a>" << endl;
os << " <b> " << setw(12) << a_[1].x << " "
<< setw(12) << a_[0].z << "\"" << endl;
os << " b=\"" << setw(12) << a_[1].x << " "
<< setw(12) << a_[1].y << " "
<< setw(12) << a_[1].z << " </b>" << endl;
os << " <c> " << setw(12) << a_[2].x << " "
<< setw(12) << a_[1].z << "\"" << endl;
os << " c=\"" << setw(12) << a_[2].x << " "
<< setw(12) << a_[2].y << " "
<< setw(12) << a_[2].z << " </c>" << endl;
<< setw(12) << a_[2].z << "\"" << " />" << endl;
}
////////////////////////////////////////////////////////////////////////////////
......
--------------------------------------------------------------------------------
rel1_36_0
Added unit cell to the sample schema. Modified AtomSet to contain a unit cell.
Included unit cell in saved samples.
--------------------------------------------------------------------------------
rel1_35_0
Implemented parallel I/O for writing sample files. Uses MPI-IO.
This does not work on BG/L with PVFS since PVFS does not support the
collective calls MPI_File_write_ordered and MPI_File_write_shared.
Option -serial added to the save command to use the old serial mode.
--------------------------------------------------------------------------------
rel1_34_4
Base64Transcoder.C: modif print functions to use larger string buffer for I/O.
SampleReader.C, SampleWriter.C: added timer.
......
......@@ -3,10 +3,10 @@
// release.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: release.C,v 1.43 2008-01-26 01:34:11 fgygi Exp $
// $Id: release.C,v 1.44 2008-02-03 22:53:55 fgygi Exp $
#include "release.h"
std::string release(void)
{
return std::string("1.35.0");
return std::string("1.36.0");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment