MADNESS  version 0.9
operator-maxwell.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31  $Id$
32 */
33 #ifndef __operator_maxwell__
34 #define __operator_maxwell__
35 
36 #include <string>
37 #include <madness/constants.h>
38 #include <madness/mra/mra.h>
39 #include <madness/tensor/gmres.h>
40 
41 using namespace std;
42 using namespace madness;
43 
45 typedef Function<complexd, 3> function;
47 
52 class EFieldOperator : public Operator<vecfunc> {
53 protected:
54  const function &epshat;
57  const Function<double, 3> &box_mask; // mask to make the boundary 0
58  const Function<double, 3> &grad_mask; // mask to damp out derivatives
60 
61  void action(const vecfunc &in, vecfunc &out) const {
62  function dotp = (gradlnepshat[0]*in[0] + gradlnepshat[1]*in[1]
63  + gradlnepshat[2]*in[2]) * box_mask;
64  vecfunc preop;
65  int i;
66 
67  for(i = 0; i < 3; ++i)
68  preop[i] = diff(dotp, i) * grad_mask;
69  dotp.clear();
70 
71  for(i = 0; i < 3; ++i) {
72  dotp = epshat*in[i];
73  dotp.compress();
74  preop[i].compress();
75  preop[i].gaxpy(complexd(1.0, 0.0), dotp, prefact);
76  out[i] = in[i] - apply(G, preop[i]);
77  out[i].truncate();
78  dotp.clear();
79  preop[i].clear();
80  }
81  }
82 
83 public:
88  EFieldOperator(const function &_epshat, const double _omega,
89  const double _mu0, const double _eps0, const vecfunc &_gradlnepshat,
90  const Function<double, 3> &_box_mask,
91  const Function<double, 3> &_grad_mask,
92  const SeparatedConvolution<double, 3> &_G) : epshat(_epshat),
93  prefact(complexd(0.0, -_omega*_eps0*_mu0)), gradlnepshat(_gradlnepshat),
94  box_mask(_box_mask), grad_mask(_grad_mask), G(_G) {}
95 };
96 
97 #endif
std::complex< double > double_complex
Definition: lineplot.cc:16
Main include file for MADNESS and defines Function interface.
double_complex complexd
Definition: operator-maxwell.h:44
Defines common mathematical and physical constants.
Vector< function, 3 > vecfunc
Definition: operator-maxwell.h:46
Definition: operator-maxwell.h:52
Definition: mpreal.h:3066
Defines a general operator interface and a templated GMRES solver for solving linear equations...
EFieldOperator(const function &_epshat, const double _omega, const double _mu0, const double _eps0, const vecfunc &_gradlnepshat, const Function< double, 3 > &_box_mask, const Function< double, 3 > &_grad_mask, const SeparatedConvolution< double, 3 > &_G)
Definition: operator-maxwell.h:88
void action(const vecfunc &in, vecfunc &out) const
The action of the operator.
Definition: operator-maxwell.h:61
const SeparatedConvolution< double, 3 > & G
Definition: operator-maxwell.h:59
const function & epshat
Definition: operator-maxwell.h:54
void clear(bool fence=true)
Clears the function as if constructed uninitialized. Optional fence.
Definition: mra.h:799
const Function< double, 3 > & box_mask
Definition: operator-maxwell.h:57
const Function< double, 3 > & grad_mask
Definition: operator-maxwell.h:58
Definition: nemo.h:65
A multiresolution adaptive numerical function.
Definition: derivative.h:61
double_complex complexd
Definition: envelopedpulse.h:44
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
A generic operator: takes in one T and produces another T.
Definition: gmres.h:62
Function< T, NDIM > apply(const Derivative< T, NDIM > &D, const Function< T, NDIM > &f, bool fence=true)
Applies derivative operator to function (for syntactic equivalence to integral operator apply) ...
Definition: derivative.h:613
const vecfunc & gradlnepshat
Definition: operator-maxwell.h:56
const complexd prefact
Definition: operator-maxwell.h:55