// Author: Egon Pavlica <http://www.ses-ng.si/~pavlica/>
#include "LSpace.h"
#include <iostream>
//________________________________________
// This class is for use to montecarlo
// simulation of charge particle in a
// disordered molecular crystal
//
// with this class we bind together
// particle properties and lattice
// properties and external field (fbias).
// The Lattice class
// is for random energy, base cell size, etc.
// The particle class knows its position,
// time and energy
//
// Lattice coordinates and particle coordinates
// are not the same. Lattice coordinates i and j
// are periodic. This is done with Lattice class.
// This means, that when the
// i > fNa then i%=fNa
// i < 1 then i%=fNa and i+=fNa
// ...
// where fNa and fNb are lattice sizes.
//
//
// Logs:
//
// $Log: LSpace.cc,v $
// Revision 1.5 2003/06/26 14:46:16 cvs
// found a bug in LSpace::GetEnergy() with fbias. Bug successfully resolved :)
//
// Revision 1.4 2003/06/26 13:26:05 cvs
// some bugs removed + some test methods implemented in LDisorder
//
// Revision 1.3 2003/06/26 11:24:25 cvs
// modified particle moving with LMiki and faster LDisorder operations
//
// Revision 1.2 2003/06/26 09:27:11 cvs
// added log fields...
//
ClassImp(LSpace)
LSpace::LSpace(){
//default constructor
fspace=0;
fe=0;
fbias=0;
if (fverbose) std::cout<<"Space createdn";
};
LSpace::~LSpace() {
//destroy Lattice and particles and free memory space used by fbias
if (fe) {delete fe; fe=0;}
if (fbias) {Tdelete(fbias,0); fbias=0;}
if (fspace) {delete fspace; fspace=0;}
if (fverbose) std::cout<<"Space killedn";
}
LSpace::LSpace(const int x,const int y,const int z){
// Create space of size x,y and z
// including Lattice (of the size 100x100x100) and adds a LParticle
// create fbias array for external field energy
// fbias is (0..fz+1) 0 is external bias at one side, while fz+1 is
// external bias at other side
fe=0;
fx=x;fy=y;fz=z;
fspace=new Lattice(100,100,100);
fe=0;
Tnew(fbias,0,fz+1);
if (fverbose) std::cout<<"Space createdn";
};
LParticle* LSpace::AddParticle(const int i,const int j,const int k){
//(re)create particle e at coordinate i,j,k
//particle energy is set
if (fe) delete fe;
fe=new LParticle();
fe->i=i;fe->j=j;fe->k=k;
fe->SetEnergy(GetEnergy(i,j,k));//sets particle energy
return fe;
}
int LSpace::IsInside(const LParticle *e)const{
//this is test method, which controls if the particle is inside the space
//currently the control is done only for z direction
//if particle is inside 1 is returned else 0 if is outside
return (e->k<=fz && e->k>0);
}
float LSpace::Distance(const int i,const int j,const int k)const {
//see Lattice::Distance
return fspace->Distance(i,j,k);
}
float LSpace::Distance(int idx){
//see Lattice::Distance
return fspace->Distance(idx);
}
void LSpace::SetBias(const int k,const float bias) {
fbias[k]=bias;
}
void
LSpace::SetBias(const float* bias) {
//copy bias array
if(!fbias) {
if (fverbose) std::cerr<<"Error LSpace:SetBiasn";
return;
}
for(int i=0;i<=fz+1;i++) {
fbias[i]=bias[i];
// if (fverbose) std::cout<<"fbias["<<i<<"]="<<fbias[i]<<"n";
}
}
float
LSpace::GetBias(const int k) const
{
if (k<0) return fbias[0];
if (k>fz) return fbias[fz+1];
return fbias[k];
};
float LSpace::GetEnergy(int i,int j,int k) const{
//see Lattice::GetEnergy - fbias[k]
//here is assumed we work with positive particles
return (fspace->GetEnergy(i,j,k)-GetBias(k));
}
float LSpace::GetEnergyDifference(int i,int j,int k,int di,int dj,int dk) const{
//see Lattice::GetEnergyDifference + (fbias[k+dk]-fbias[k])
return fspace->GetEnergyDifference(i,j,k,di,dj,dk)+(fbias[k]-fbias[k+dk]);
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.