1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2018 The Regents of the University of California
4 //
5 // This file is part of Qbox
6 //
7 // Qbox is distributed under the terms of the GNU General Public License
8 // as published by the Free Software Foundation, either version 2 of
9 // the License, or (at your option) any later version.
10 // See the file COPYING in the root directory of this distribution
11 // or <http://www.gnu.org/licenses/>.
12 //
13 ////////////////////////////////////////////////////////////////////////////////
14 //
15 // test_vext.cpp
16 //
17 // Generate an external potential in XML format for input to the response
18 // command.
19 // vext = sine wave in the x direction
20 // use: test_vext a b c np0 np1 np2
21 //
22 ////////////////////////////////////////////////////////////////////////////////
23
24 #include "Function3d.h"
25 #include<cassert>
26 #include<vector>
27 #include<string>
28 using namespace std;
29
30 ////////////////////////////////////////////////////////////////////////////////
main(int argc,char ** argv)31 int main(int argc, char **argv)
32 {
33 if ( argc == 1 )
34 {
35 cerr << "use: test_vext a b c np0 np1 np2" << endl;
36 return 1;
37 }
38 double a = atof(argv[1]);
39 double b = atof(argv[2]);
40 double c = atof(argv[3]);
41 Function3d f;
42 f.a = D3vector(a,0,0);
43 f.b = D3vector(0,b,0);
44 f.c = D3vector(0,0,c);
45 f.nx = atoi(argv[4]);
46 f.ny = atoi(argv[5]);
47 f.nz = atoi(argv[6]);
48 f.val.resize(f.nx*f.ny*f.nz);
49 f.name = "delta_v";
50 for ( int i = 0; i < f.nx; i++ )
51 for ( int j = 0; j < f.ny; j++ )
52 for ( int k = 0; k < f.nz; k++ )
53 {
54 double x = ( a * i ) / f.nx;
55 double y = ( b * j ) / f.ny;
56 double z = ( c * k ) / f.nz;
57 f.val[i+f.nx*(j+f.ny*k)] = sin(2*M_PI*x/a);
58 }
59 cout << f;
60 return 0;
61 }
62