patom.cpp

来自「An object-oriented C++ implementation of」· C++ 代码 · 共 67 行

CPP
67
字号

#include "../davidson/pAtom.h"
#include <math.h>

PotentialAtom::PotentialAtom(const ftyp &a, const ftyp &V0):
			 PotentialBase()
{
	typV=2;
	PotentialAtom::a=a;
    PotentialAtom::V0=V0;
}

ftyp PotentialAtom::VCoulomb(const ftyp &x) const
{    if (fabs(x)<0.000000001) return -V0*1000000000;    return -V0/fabs(x);}ftyp PotentialAtom::VCoulomb(const ftyp &x, const ftyp &y) const{    ftyp r2 = x*x+y*y;    if (r2<0.0000000001) return -V0*100000;    return -V0/sqrt(r2);}ftyp PotentialAtom::VCoulomb(const ftyp &x, const ftyp &y, const ftyp &z) const{    ftyp r2 = x*x+y*y+z*z;    if (r2<0.0000000001) return -V0*100000;    return -V0/sqrt(r2);}ftyp PotentialAtom::operator()(const ftyp &x) const{    if (a) return -V0/sqrt(a*a+x*x);    return VCoulomb(x);}ftyp PotentialAtom::operator()(const ftyp &x, const ftyp &y) const{    if (a) return -V0/sqrt(a*a+x*x+y*y);    return VCoulomb(x,y);}ftyp PotentialAtom::operator()(const ftyp &x, const ftyp &y, const ftyp &z) const{    if (a) return -V0/sqrt(a*a+x*x+y*y+z*z);    return VCoulomb(x,y,z);}

void PotentialAtom::SetAV0(const ftyp &a, const ftyp &V0)
{    PotentialAtom::a  = a;    PotentialAtom::V0 = V0;}ftyp PotentialAtom::GetV0() const{	return V0;}ftyp PotentialAtom::GetA() const{	return a;}
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?