diff --git a/src/Makefile b/src/Makefile index 2c63895..bb66f90 100644 --- a/src/Makefile +++ b/src/Makefile @@ -136,6 +136,9 @@ CXXFLAGS += -DTARGET='"$(TARGET)"' testFunction3d: testFunction3d.o Function3d.o Function3dHandler.o \ Base64Transcoder.o qbox_xmlns.o $(PLTOBJECTS) $(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS) + test_vext: test_vext.o Function3d.o Function3dHandler.o \ + Base64Transcoder.o qbox_xmlns.o $(PLTOBJECTS) + $(LD) $(DFLAGS) -o $@ $^ $(LDFLAGS) #------------------------------------------------------------------------------ # generate dependencies in makefile: use -Y to avoid library header files # that are likely to be different on other platforms. @@ -579,8 +582,7 @@ ResponseCmd.o: blacs.h D3vector.h Wavefunction.h UnitCell.h SlaterDet.h ResponseCmd.o: Basis.h Sample.h AtomSet.h Atom.h D3tensor.h blas.h ResponseCmd.o: ConstraintSet.h ExtForceSet.h Control.h ChargeDensity.h ResponseCmd.o: ExternalPotential.h FourierTransform.h ResponseCmd.h -ResponseCmd.o: UserInterface.h release.h isodate.h Species.h -ResponseCmd.o: Base64Transcoder.h qbox_xmlns.h +ResponseCmd.o: UserInterface.h release.h isodate.h Species.h Function3d.h ResponseCmd.o: UserInterface.h RseedCmd.o: UserInterface.h Sample.h AtomSet.h Context.h blacs.h Atom.h RseedCmd.o: D3vector.h UnitCell.h D3tensor.h blas.h ConstraintSet.h @@ -820,6 +822,7 @@ testWavefunction.o: SlaterDet.h Basis.h Matrix.h Timer.h testXCFunctional.o: LDAFunctional.h XCFunctional.h PBEFunctional.h Timer.h testXMLGFPreprocessor.o: Context.h blacs.h Matrix.h XMLGFPreprocessor.h test_fftw.o: Timer.h readTSC.h +test_vext.o: Function3d.h D3vector.h testjacobi.o: Timer.h Context.h blacs.h Matrix.h jacobi.h testjade.o: Timer.h Context.h blacs.h Matrix.h jade.h uuid_str.o: uuid_str.h diff --git a/src/test_vext.C b/src/test_vext.C new file mode 100644 index 0000000..32559b6 --- /dev/null +++ b/src/test_vext.C @@ -0,0 +1,61 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2018 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 . +// +//////////////////////////////////////////////////////////////////////////////// +// +// test_vext.C: +// +// Generate an external potential in XML format for input to the response +// command. +// vext = sine wave in the x direction +// use: test_vext a b c np0 np1 np2 +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Function3d.h" +#include +#include +#include +using namespace std; + +//////////////////////////////////////////////////////////////////////////////// +int main(int argc, char **argv) +{ + if ( argc == 1 ) + { + cerr << "use: test_vext a b c np0 np1 np2" << endl; + return 1; + } + double a = atof(argv[1]); + double b = atof(argv[2]); + double c = atof(argv[3]); + Function3d f; + f.a = D3vector(a,0,0); + f.b = D3vector(0,b,0); + f.c = D3vector(0,0,c); + f.nx = atoi(argv[4]); + f.ny = atoi(argv[5]); + f.nz = atoi(argv[6]); + f.val.resize(f.nx*f.ny*f.nz); + f.name = "delta_v"; + for ( int i = 0; i < f.nx; i++ ) + for ( int j = 0; j < f.ny; j++ ) + for ( int k = 0; k < f.nz; k++ ) + { + double x = ( a * i ) / f.nx; + double y = ( b * j ) / f.ny; + double z = ( c * k ) / f.nz; + f.val[i+f.nx*(j+f.ny*k)] = sin(2*M_PI*x/a); + } + cout << f; + return 0; +}