1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
#ifndef CHARGE_REGULATOR_H
#define CHARGE_REGULATOR_H
#include "AtomicRegulator.h"
#include "PoissonSolver.h"
#include <map>
#include <utility>
#include <string>
#include <vector>
namespace ATC {
/**
* @class ChargeRegulator
* @brief Manager class for atom-continuum control of charge and potential
*/
class ChargeRegulatorMethod;
class ChargeRegulator : public AtomicRegulator {
public:
/** charge regulator types */
enum ChargeRegulatorType {
NONE=0,
FEEDBACK,
IMAGE_CHARGE,
EFFECTIVE_CHARGE
};
enum ChargedSurfaceType {
INSULATOR=0,
DIELECTRIC,
CONDUCTOR
};
/** parser data */
struct ChargeRegulatorParameters {
ChargeRegulatorParameters():
method(NONE),
value(0),
groupBit(0),
depth(0),
permittivity(0),
surfaceType(INSULATOR) { };
ChargeRegulatorType method;
double value;
int groupBit;
std::string groupTag;
double depth;
double permittivity;
ChargedSurfaceType surfaceType;
FSET faceset;
};
/** constructor */
ChargeRegulator(ATC_Coupling *atc);
/** destructor */
~ChargeRegulator();
/** parser/modifier */
virtual bool modify(int narg, char **arg);
virtual void construct_methods();
virtual void initialize();
virtual void apply_pre_force(double dt);
virtual void apply_post_force(double dt);
virtual void output(OUTPUT_LIST & outputData) const;
virtual double compute_vector(int /* n */) const {return 0;} // TODO
void assign_poisson_solver(PoissonSolver * solver) { poissonSolver_ = solver;}
PoissonSolver * poisson_solver(void) { return poissonSolver_;}
protected:
/** poisson solver */
PoissonSolver * poissonSolver_;
/** registry charge regulators */
std::map<std::string,ChargeRegulatorMethod *> regulators_;
std::map<std::string,ChargeRegulatorParameters> parameters_;
private:
ChargeRegulator(); // DO NOT define this
};
/**
* @class ChargeRegulatorMethod
* @brief Base class for implementation of ChargeRegulator algorithms
*/
class ChargeRegulatorMethod : public RegulatorShapeFunction {
public:
ChargeRegulatorMethod(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & parameters);
~ChargeRegulatorMethod(){};
virtual void initialize(void);
void set_greens_functions();
virtual void apply_pre_force(double /* dt */){};
virtual void apply_post_force(double /* dt */){};
virtual void set_weights() {};
const DENS_VEC & total_influence() const { return sum_;}
virtual void output(OUTPUT_LIST & outputData);
protected:
int nlocal();
/** pointer to charge regulator object for data */
ChargeRegulator * chargeRegulator_;
/** interscale manager */
class InterscaleManager * interscaleManager_;
/** direct interface to lammps */
class LammpsInterface * lammpsInterface_;
/** poisson solver */
PoissonSolver * poissonSolver_;
/** (subset) of Green's functions */
std::vector<SparseVector<double> > greensFunctions_;
/** cutoff radius */
double rC_,rCsq_;
/** conversion constants */
double qV2e_, qqrd2e_;
/** member data */
XT_Function * targetValue_;
double targetPhi_;
// controlling
FSET surface_;
NSET nodes_;
int atomGroupBit_;
bool boundary_; // atoms on boundary
DENS_VEC point_;
DENS_VEC normal_;
double depth_;
ChargeRegulator::ChargedSurfaceType surfaceType_;
double permittivity_;
bool initialized_;
DENS_VEC sum_;
/** workspace */
mutable DENS_MAT _atomElectricalForce_;
private:
ChargeRegulatorMethod(); // DO NOT define this
};
/**
* @class ChargeRegulatorMethodFeedback
* @brief ChargeRegulator with feedback and ad hoc positions
* can be used for conductor (1 charged sheet) or insulator (2 sheets)
*/
class ChargeRegulatorMethodFeedback : public ChargeRegulatorMethod {
public:
/** constructor */
ChargeRegulatorMethodFeedback(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & parameters);
/** destructor */
~ChargeRegulatorMethodFeedback(){};
/** instantiate all needed data */
virtual void construct_transfers();
/** initialize */
virtual void initialize(void);
/** set influence nodes and atoms */
void set_influence();
void set_influence_matrix(void);
/** post first verlet step */
virtual void apply_pre_force(double dt);
void apply_feedback_charges();
protected:
int nControlNodes_;
NSET & controlNodes_;
// measurement/controlled
int influenceGroupBit_;
int nInfluenceAtoms_;
NSET influenceAtoms_, influenceAtomsIds_;
int nInfluenceNodes_;
NSET influenceNodes_;
DENS_MAT invG_;
DENS_MAT invNNT_;
DENS_MAT NT_;
DENS_MAT NTinvNNTinvG_;
private:
ChargeRegulatorMethodFeedback(); // DO NOT define this
};
/**
* @class ChargeRegulatorMethodImageCharge
* @brief ChargeRegulator with image charges
*/
class ChargeRegulatorMethodImageCharge : public ChargeRegulatorMethod {
public:
/** constructor */
ChargeRegulatorMethodImageCharge(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & parameters);
/** destructor */
~ChargeRegulatorMethodImageCharge(){};
/** initialize */
virtual void initialize(void);
/** post first verlet step */
virtual void apply_post_force(double dt);
protected:
double reflect(DENS_VEC & x) const {
double dn = (x-point_).dot(normal_);
x -= 2*dn*normal_;
return dn;
}
// internal functions
void apply_local_forces();
void correct_charge_densities();
void correct_forces();
double layerDepth_;
double permittivityRatio_;
NSET & imageNodes_;
DENS_MAT imageTransferOp_;
private:
ChargeRegulatorMethodImageCharge(); // DO NOT define this
};
/**
* @class ChargeRegulatorMethodEffectiveCharge
* @brief ChargeRegulator with effective charges at FE quadrature pts
*/
class ChargeRegulatorMethodEffectiveCharge : public ChargeRegulatorMethod {
typedef std::map<int,std::pair<DENS_VEC,double> > NODE_TO_XF_MAP;
public:
/** constructor */
ChargeRegulatorMethodEffectiveCharge(ChargeRegulator *chargeRegulator,
ChargeRegulator::ChargeRegulatorParameters & parameters);
/** destructor */
~ChargeRegulatorMethodEffectiveCharge(){};
/** initialize */
virtual void initialize(void);
/** post first verlet step */
virtual void apply_post_force(double dt);
protected:
// internal functions
void apply_local_forces();
// member data
double chargeDensity_;
std::map<int,double> nodalChargePotential_;
NODE_TO_XF_MAP nodeXFMap_;
bool useSlab_;
private:
ChargeRegulatorMethodEffectiveCharge(); // DO NOT define this
};
};
#endif
|