Debug_GridFF_Tricubic - ProkopHapala/FireCore GitHub Wiki

GridFF surface offset(s)

gridFF.grid.pos0 and gridFF.shift0

inline Quat4d GridFF::getForce_Bspline( Vec3d p, const Quat4d& PLQH, bool bSurf=true ) const {
    //p.sub(shift0);
    p.sub(grid.pos0);   // HERE    shift here
    grid.diCell.dot_to( p, t );
    Quat4d fe = Bspline::fe3d_pbc_comb3( t, grid.n, Bspline_PLQ, PLQH.f, cubic_xqis, cubic_yqis ); 
    // ...
}
    void GridFF::evalBsplineRef(int natoms_, Vec3d * apos_, Quat4d * REQs_, double* VPaul, double* VLond, double* VCoul ){
        // ...
        for(int i=0; i<ntot; i++){
            const Vec3d pos = grid.pos0 + grid.dCell.c*iz + grid.dCell.b*iy + grid.dCell.a*ix;
            Quat4d qp,ql;evalGridFFPoint_Mors( npbc_mors, shift_mors,  natoms_, apos_, REQs_, pos, qp, ql );
            // ...
        }
        // ...
    }
    virtual void MolWorld_sp3::initGridFF( const char * name, double z0=NAN, Vec3d cel0={-0.5,-0.5,0.0}, bool bSymetrize=true, bool bAutoNPBC=true, bool bCheckEval=true, bool bUseEwald=true, bool bFit=true, bool bRefine=true ){
        gridFF.grid.center_cell( cel0 );
        ...
        gridFF.initGridFF( name, z0, bAutoNPBC, bSymetrize );
        ...
        gridFF.shift0 = Vec3d{0.,0.,-2.0};
    }

z0

z0 set here in python interface

def makeGridFF( name, mode=1, z0=0.0, cel0=[-0.5,-0.5,0.0], bSymmetrize=False, bAutoNPBC=True, bFit=True, bRefine=True ):
    # ...
    lib.makeGridFF( name,  _np_as(ffshape,c_int_p), mode, int(z0), _np_as(cel0,c_double_p), bSymmetrize, bAutoNPBC, bFit, bRefine )

Grids seems shifted by few pixels

Charge Grid

  • GridFF::tryLoadGridFF_potentials() in GridFF.h
std::vector<Vec3d>  ps(natoms_); for( int i=0; i<natoms_; i++ ){  Vec3d p=apos_[i];  p.z-=grid.dCell.c.z; ps[i]=p; } // NOTE: For some unknown reason we have to shift atoms by 1 pixel in z-direction (perhaps something about grid alignement)

But even I overcome this, there is still some additional shift

  • This shift does not depend on niter in laplace_real_loop_inert()

Se this block in print( "GridFF_cl::makeCoulombEwald_slab() " ) in /pyBall/OCL/GridFF.py

# NOTE / TODO : This is strange, not sure why we need to shift the coordinates
atoms_np[:,0] += self.gcl.dg[0] * 1 
atoms_np[:,1] += self.gcl.dg[1] * 1
atoms_np[:,2] += self.gcl.dg[2] * (-1 + 4)   # NOTE / TODO : shift -1 is because we do the same shift on CPU (in GridFF::tryLoadGridFF_potentials() ), this make sure that Qgrid_gpu and Qgrid_cpu are the same.   But align V_Coul with CPU we need to shift by 4 (see below)
⚠️ **GitHub.com Fallback** ⚠️