////////////////////////////////////////////////////////////////////////////////
//
// 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 .
//
////////////////////////////////////////////////////////////////////////////////
//
// SampleStepper.C
//
////////////////////////////////////////////////////////////////////////////////
// $Id: SampleStepper.C,v 1.25 2008-09-08 15:56:19 fgygi Exp $
#include "SampleStepper.h"
#include "Sample.h"
#include "Species.h"
#include
#include
using namespace std;
////////////////////////////////////////////////////////////////////////////////
SampleStepper::SampleStepper(Sample& s) : s_(s)
{
fion.resize(s_.atoms.nsp());
for ( int is = 0; is < fion.size(); is++ )
fion[is].resize(3*s_.atoms.na(is));
sigma_eks.resize(6);
sigma_kin.resize(6);
sigma_ext.resize(6);
sigma.resize(6);
sigma_ext = valarray(s.ctrl.ext_stress,6);
const double gpa = 29421.5;
sigma_ext /= gpa;
}
////////////////////////////////////////////////////////////////////////////////
SampleStepper::~SampleStepper(void)
{
// print timer map
for ( TimerMap::iterator i = tmap.begin(); i != tmap.end(); i++ )
{
double time = (*i).second.real();
double tmin = time;
double tmax = time;
s_.ctxt_.dmin(1,1,&tmin,1);
s_.ctxt_.dmax(1,1,&tmax,1);
if ( s_.ctxt_.myproc()==0 )
{
cout << ""
<< endl;
}
}
}
////////////////////////////////////////////////////////////////////////////////
void SampleStepper::print_stress(void)
{
const double gpa = 29421.5;
if ( s_.ctxt_.onpe0() )
{
cout.setf(ios::fixed,ios::floatfield);
cout.setf(ios::right,ios::adjustfield);
cout << setprecision(8);
cout << " " << endl;
cout << " " << setw(12) << sigma_eks[0]*gpa
<< " \n"
<< " " << setw(12) << sigma_eks[1]*gpa
<< " \n"
<< " " << setw(12) << sigma_eks[2]*gpa
<< " \n"
<< " " << setw(12) << sigma_eks[3]*gpa
<< " \n"
<< " " << setw(12) << sigma_eks[4]*gpa
<< " \n"
<< " " << setw(12) << sigma_eks[5]*gpa
<< " \n\n";
cout << " " << setw(12) << sigma_kin[0]*gpa
<< " \n"
<< " " << setw(12) << sigma_kin[1]*gpa
<< " \n"
<< " " << setw(12) << sigma_kin[2]*gpa
<< " \n"
<< " " << setw(12) << sigma_kin[3]*gpa
<< " \n"
<< " " << setw(12) << sigma_kin[4]*gpa
<< " \n"
<< " " << setw(12) << sigma_kin[5]*gpa
<< " \n\n";
cout << " " << setw(12) << sigma_ext[0]*gpa
<< " \n"
<< " " << setw(12) << sigma_ext[1]*gpa
<< " \n"
<< " " << setw(12) << sigma_ext[2]*gpa
<< " \n"
<< " " << setw(12) << sigma_ext[3]*gpa
<< " \n"
<< " " << setw(12) << sigma_ext[4]*gpa
<< " \n"
<< " " << setw(12) << sigma_ext[5]*gpa
<< " \n\n";
cout << " " << setw(12) << sigma[0]*gpa
<< " \n"
<< " " << setw(12) << sigma[1]*gpa
<< " \n"
<< " " << setw(12) << sigma[2]*gpa
<< " \n"
<< " " << setw(12) << sigma[3]*gpa
<< " \n"
<< " " << setw(12) << sigma[4]*gpa
<< " \n"
<< " " << setw(12) << sigma[5]*gpa
<< " \n";
cout << " " << endl;
}
}
////////////////////////////////////////////////////////////////////////////////
void SampleStepper::compute_sigma(void)
{
sigma_kin = 0.0;
// compute kinetic contribution to stress using velocities at time t0
for ( int is = 0; is < s_.atoms.atom_list.size(); is++ )
{
int i = 0;
double mass = s_.atoms.species_list[is]->mass() * 1822.89;
for ( int ia = 0; ia < s_.atoms.atom_list[is].size(); ia++ )
{
Atom* pa = s_.atoms.atom_list[is][ia];
D3vector v = pa->velocity();
const double vx = v.x;
const double vy = v.y;
const double vz = v.z;
sigma_kin[0] += mass * vx * vx;
sigma_kin[1] += mass * vy * vy;
sigma_kin[2] += mass * vz * vz;
sigma_kin[3] += mass * vx * vy;
sigma_kin[4] += mass * vy * vz;
sigma_kin[5] += mass * vx * vz;
i += 3;
}
}
sigma_kin /= s_.wf.cell().volume();
sigma = sigma_eks + sigma_kin - sigma_ext;
}