~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/atc/Thermostat.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
  
75
75
  public:
76
76
  
77
 
    ThermostatShapeFunction(Thermostat * thermostat,
 
77
    ThermostatShapeFunction(AtomicRegulator * thermostat,
78
78
                            const std::string & regulatorPrefix = "");
79
79
        
80
80
    virtual ~ThermostatShapeFunction() {};
89
89
    virtual void set_weights();
90
90
 
91
91
    // member data
92
 
    /** pointer to thermostat object for data */
93
 
    Thermostat * thermostat_;
94
 
 
95
92
    
96
93
    /** MD mass matrix */
97
94
    DIAG_MAN & mdMassMatrix_;  
117
114
  class ThermostatRescale : public ThermostatShapeFunction {
118
115
  
119
116
  public:
 
117
 
 
118
    friend class KinetoThermostatRescale; // since this is sometimes used as a set of member functions for friend
120
119
  
121
 
    ThermostatRescale(Thermostat * thermostat);
 
120
    ThermostatRescale(AtomicRegulator * thermostat);
122
121
        
123
122
    virtual ~ThermostatRescale() {};
124
123
 
128
127
    /** applies thermostat to atoms in the post-corrector phase */
129
128
    virtual void apply_post_corrector(double dt);
130
129
 
 
130
    /** compute boundary flux, requires thermostat input since it is part of the coupling scheme */
 
131
    virtual void compute_boundary_flux(FIELDS & fields)
 
132
      {boundaryFlux_[TEMPERATURE] = 0.;};
 
133
 
131
134
    /** get data for output */
132
135
    virtual void output(OUTPUT_LIST & outputData);
133
136
        
134
137
  protected:
135
138
 
 
139
    /** set weighting factor for in matrix Nhat^T * weights * Nhat */
 
140
    virtual void set_weights();
 
141
 
 
142
    /** sets up and solves thermostat equations */
 
143
    virtual void compute_thermostat(double dt);
 
144
 
136
145
    /** apply solution to atomic quantities */
137
146
    void apply_to_atoms(PerAtomQuantity<double> * atomVelocities);
138
147
 
139
 
    /** correct the RHS for complex temperature definitions */
140
 
    virtual void correct_rhs(DENS_MAT & rhs) {};  // base class does no correction, assuming kinetic definition
 
148
    /** construct the RHS vector */
 
149
    virtual void set_rhs(DENS_MAT & rhs);
141
150
        
142
151
    /** FE temperature field */
143
152
    DENS_MAN & nodalTemperature_;
165
174
  
166
175
  public:
167
176
  
168
 
    ThermostatRescaleMixedKePe(Thermostat * thermostat);
 
177
    ThermostatRescaleMixedKePe(AtomicRegulator * thermostat);
169
178
        
170
179
    virtual ~ThermostatRescaleMixedKePe() {};
171
180
 
177
186
        
178
187
  protected:
179
188
 
180
 
    /** correct the RHS for inclusion of the PE */
181
 
    virtual void correct_rhs(DENS_MAT & rhs);
 
189
    /** set weighting factor for in matrix Nhat^T * weights * Nhat */
 
190
    virtual void set_weights();
 
191
 
 
192
    /** construct the RHS vector */
 
193
    virtual void set_rhs(DENS_MAT & rhs);
182
194
 
183
195
    /** nodal fluctuating potential energy */
184
196
    DENS_MAN * nodalAtomicFluctuatingPotentialEnergy_;
196
208
  
197
209
  };
198
210
 
 
211
    /**
 
212
   *  @class  ThermostatFsSolver
 
213
   *  @brief  Class for solving the linear system for lambda
 
214
   *          (thermostats have general for of N^T w N lambda = rhs)
 
215
   */
 
216
  
 
217
  class ThermostatFsSolver : public RegulatorShapeFunction {
 
218
 
 
219
  
 
220
  public:
 
221
  
 
222
    ThermostatFsSolver(AtomicRegulator * thermostat,
 
223
                       int lambdaMaxIterations,
 
224
                       const std::string & regulatorPrefix = "");
 
225
        
 
226
    virtual ~ThermostatFsSolver() {};
 
227
 
 
228
    /** pre-run initialization of method data */
 
229
    virtual void initialize();
 
230
 
 
231
    /* sets up and solves the linear system for lambda */
 
232
    virtual void compute_lambda(const DENS_MAT & rhs,
 
233
                                bool iterateSolution = true);
 
234
 
 
235
    /* scales lambda */
 
236
    virtual void scale_lambda(double factor) {*lambda_ *= factor;};
 
237
 
 
238
    /** change the time step factor */
 
239
    virtual void set_timestep_factor(double dtFactor) {dtFactor_ = dtFactor;};
 
240
 
 
241
  protected:
 
242
 
 
243
    // methods  
 
244
    /** solves the non-linear equation for lambda iteratively */
 
245
    void iterate_lambda(const MATRIX & rhs);
 
246
 
 
247
    /** set weighting factor for in matrix Nhat^T * weights * Nhat */
 
248
    virtual void set_weights();
 
249
 
 
250
    // data
 
251
    /** mapping from all to regulated nodes */
 
252
    DENS_MAT rhsMap_;
 
253
 
 
254
    /** maximum number of iterations used in iterative solve for lambda */
 
255
    int lambdaMaxIterations_;
 
256
 
 
257
    /** pointer to the values of lambda interpolated to atoms */
 
258
    DENS_MAN * rhsLambdaSquared_;
 
259
 
 
260
    /** fraction of timestep over which constraint is exactly enforced */
 
261
    double dtFactor_;
 
262
 
 
263
    // workspace
 
264
    DENS_MAT _lambdaOld_; // lambda from previous iteration
 
265
    DENS_MAT _rhsOverlap_; // normal RHS vector mapped to overlap nodes
 
266
    DENS_VEC _rhsTotal_; // normal + 2nd order RHS for the iteration loop
 
267
    DENS_VEC _weightVector_, _maskedWeightVector_;
 
268
 
 
269
  private:
 
270
 
 
271
    // DO NOT define this
 
272
    ThermostatFsSolver();
 
273
 
 
274
  };
 
275
 
199
276
  /**
200
277
   *  @class  ThermostatGlcFs
201
 
   *  @brief  Class for thermostat algorithms based on Gaussian least constraints (GLC) for fractional step (FS) algorithsm
 
278
   *  @brief  Class for thermostat algorithms which perform the time-integration component of the fractional step method
202
279
   */
203
280
  
204
 
  class ThermostatGlcFs : public ThermostatShapeFunction {
 
281
  class ThermostatGlcFs : public RegulatorMethod {
205
282
  
206
283
  public:
207
284
  
208
 
    ThermostatGlcFs(Thermostat * thermostat,
 
285
    ThermostatGlcFs(AtomicRegulator * thermostat,
 
286
                    int lambdaMaxIterations,
209
287
                    const std::string & regulatorPrefix = "");
210
288
        
211
289
    virtual ~ThermostatGlcFs() {};
225
303
    /** applies thermostat to atoms in the post-corrector phase */
226
304
    virtual void apply_post_corrector(double dt);
227
305
    
 
306
    /** compute boundary flux, requires regulator input since it is part of the coupling scheme */
 
307
    virtual void compute_boundary_flux(FIELDS & fields);
 
308
    
228
309
    /** get data for output */
229
310
    virtual void output(OUTPUT_LIST & outputData);
230
311
 
231
312
    /* flag for performing the full lambda prediction calculation */
232
313
    bool full_prediction();
233
314
 
 
315
    /** set up atom to material identification */
 
316
    virtual void reset_atom_materials(const Array<int> & elementToMaterialMap,
 
317
                                      const MatrixDependencyManager<DenseMatrix, int> * atomElement);
 
318
 
234
319
  protected:
235
320
 
236
321
    // methods
237
 
    /** determine mapping from all nodes to those to which the thermostat applies */
238
 
    void compute_rhs_map();
239
 
 
240
322
    /** sets up appropriate rhs for thermostat equations */
241
323
    virtual void set_thermostat_rhs(DENS_MAT & rhs,
242
324
                                    double dt) = 0;
257
339
    virtual void compute_lambda(double dt,
258
340
                                bool iterateSolution = true);
259
341
 
260
 
    /** solves the non-linear equation for lambda iteratively */
261
 
    void iterate_lambda(const MATRIX & rhs);
262
 
 
263
342
    // member data
 
343
    /** solver for lambda linear system */
 
344
    ThermostatFsSolver * lambdaSolver_;
 
345
 
 
346
    
 
347
    /** MD mass matrix */
 
348
    DIAG_MAN & mdMassMatrix_;  
 
349
 
 
350
    /** pointer to atom velocities */
 
351
    FundamentalAtomQuantity * atomVelocities_;
 
352
 
264
353
    /** reference to AtC FE temperature */
265
354
    DENS_MAN & temperature_;
266
355
 
273
362
    /** filtered lambda power */
274
363
    DENS_MAN * lambdaPowerFiltered_;
275
364
 
 
365
    /** lambda at atomic locations */
 
366
    PerAtomQuantity<double> * atomLambdas_;
 
367
 
276
368
    /** atomic force induced by lambda */
277
369
    AtomicThermostatForce * atomThermostatForces_;
278
370
 
279
371
    /** pointer to atom masses */
280
372
    FundamentalAtomQuantity * atomMasses_;
281
373
 
282
 
    /** pointer to the values of lambda interpolated to atoms */
283
 
    DENS_MAN * rhsLambdaSquared_;
284
 
 
285
374
    /** hack to determine if first timestep has been passed */
286
375
    bool isFirstTimestep_;
287
376
 
288
 
    /** maximum number of iterations used in iterative solve for lambda */
289
 
    int lambdaMaxIterations_;
290
 
 
291
377
    /** nodal atomic energy */
292
378
    DENS_MAN * nodalAtomicEnergy_;
293
379
 
309
395
    /** right-hand side data for thermostat equation */
310
396
    DENS_MAT rhs_;
311
397
 
312
 
    /** mapping from all to regulated nodes */
313
 
    DENS_MAT rhsMap_;
314
 
 
315
 
    /** fraction of timestep over which constraint is exactly enforced */
316
 
    double dtFactor_;
317
 
 
318
398
    // workspace
319
399
    DENS_MAT _lambdaPowerOutput_; // power applied by lambda in output format
320
400
    DENS_MAT _velocityDelta_; // change in velocity when lambda force is applied
321
401
    DENS_VEC _lambdaOverlap_; // lambda in MD overlapping FE nodes
322
 
    DENS_MAT _lambdaOld_; // lambda from previous iteration
323
 
    DENS_MAT _rhsOverlap_; // normal RHS vector mapped to overlap nodes
324
 
    DENS_VEC _rhsTotal_; // normal + 2nd order RHS for the iteration loop
325
402
 
326
403
  private:
327
404
 
331
408
  };
332
409
 
333
410
  /**
334
 
   *  @class  ThermostatFlux
 
411
   *  @class  ThermostatSolverFlux
335
412
   *  @brief  Class enforces GLC on atomic forces based on FE power when using fractional step time integration
336
413
   */
337
414
 
338
 
  class ThermostatFlux : public ThermostatGlcFs {
 
415
  class ThermostatSolverFlux : public ThermostatFsSolver {
339
416
  
340
417
  public:
341
418
  
342
 
    ThermostatFlux(Thermostat * thermostat,
343
 
                   const std::string & regulatorPrefix = "");
 
419
    ThermostatSolverFlux(AtomicRegulator * thermostat,
 
420
                         int lambdaMaxIterations,
 
421
                         const std::string & regulatorPrefix = "");
344
422
        
345
 
    virtual ~ThermostatFlux() {};
 
423
    virtual ~ThermostatSolverFlux() {};
346
424
 
347
425
    /** instantiate all needed data */
348
426
    virtual void construct_transfers();
 
427
       
 
428
  protected:
 
429
 
 
430
    // methods
 
431
    /** sets up the transfer which is the set of nodes being regulated */
 
432
    virtual void construct_regulated_nodes();
 
433
 
 
434
  private:
 
435
 
 
436
    // DO NOT define this
 
437
    ThermostatSolverFlux();
 
438
 
 
439
  };
 
440
 
 
441
  /**
 
442
   *  @class  ThermostatIntegratorFlux
 
443
   *  @brief  Class integrates GLC on atomic forces based on FE power when using fractional step time integration
 
444
   */
 
445
 
 
446
  class ThermostatIntegratorFlux : public ThermostatGlcFs {
 
447
  
 
448
  public:
 
449
  
 
450
    ThermostatIntegratorFlux(AtomicRegulator * thermostat,
 
451
                             int lambdaMaxIterations,
 
452
                             const std::string & regulatorPrefix = "");
 
453
        
 
454
    virtual ~ThermostatIntegratorFlux() {};
349
455
 
350
456
    /** pre-run initialization of method data */
351
457
    virtual void initialize();
361
467
                               DENS_MAT & deltaEnergy,
362
468
                               double dt);
363
469
 
364
 
    /** sets up the transfer which is the set of nodes being regulated */
365
 
    virtual void construct_regulated_nodes();
366
 
 
367
470
    // data
368
471
    /** reference to ATC sources coming from prescribed data, AtC coupling, and extrinsic coupling */
369
472
    DENS_MAN & heatSource_;
371
474
  private:
372
475
 
373
476
    // DO NOT define this
374
 
    ThermostatFlux();
 
477
    ThermostatIntegratorFlux();
375
478
 
376
479
  };
377
480
 
378
481
  /**
379
 
   *  @class  ThermostatFixed
 
482
   *  @class  ThermostatSolverFixed
380
483
   *  @brief  Class enforces GLC on atomic forces based on FE power when using fractional step time integration
381
484
   */
382
485
 
383
 
  class ThermostatFixed : public ThermostatGlcFs {
384
 
  
385
 
  public:
386
 
  
387
 
    ThermostatFixed(Thermostat * thermostat,
388
 
                    const std::string & regulatorPrefix = "");
389
 
        
390
 
    virtual ~ThermostatFixed() {};
 
486
  class ThermostatSolverFixed : public ThermostatFsSolver {
 
487
  
 
488
  public:
 
489
  
 
490
    ThermostatSolverFixed(AtomicRegulator * thermostat,
 
491
                          int lambdaMaxIterations,
 
492
                          const std::string & regulatorPrefix = "");
 
493
        
 
494
    virtual ~ThermostatSolverFixed() {};
 
495
 
 
496
    /** instantiate all needed data */
 
497
    virtual void construct_transfers();
 
498
       
 
499
  protected:
 
500
 
 
501
    // methods
 
502
    /** sets up the transfer which is the set of nodes being regulated */
 
503
    virtual void construct_regulated_nodes();
 
504
 
 
505
   private:
 
506
 
 
507
    // DO NOT define this
 
508
    ThermostatSolverFixed();
 
509
 
 
510
  };
 
511
 
 
512
  /**
 
513
   *  @class  ThermostatIntegratorFixed
 
514
   *  @brief  Class integrates GLC on atomic forces based on FE power when using fractional step time integration
 
515
   */
 
516
 
 
517
  class ThermostatIntegratorFixed : public ThermostatGlcFs {
 
518
  
 
519
  public:
 
520
  
 
521
    ThermostatIntegratorFixed(AtomicRegulator * thermostat,
 
522
                              int lambdaMaxIterations,
 
523
                              const std::string & regulatorPrefix = "");
 
524
        
 
525
    virtual ~ThermostatIntegratorFixed() {};
391
526
 
392
527
    /** instantiate all needed data */
393
528
    virtual void construct_transfers();
436
571
    /** flag for halving the applied force to mitigate numerical errors */
437
572
    bool halve_force();
438
573
 
439
 
    /** sets up the transfer which is the set of nodes being regulated */
440
 
    virtual void construct_regulated_nodes();
441
 
 
442
574
    // data
443
575
    /** change in FE energy over a timestep */
444
576
    DENS_MAT deltaFeEnergy_;
470
602
  private:
471
603
 
472
604
    // DO NOT define this
473
 
    ThermostatFixed();
 
605
    ThermostatIntegratorFixed();
474
606
 
475
607
  };
476
608
 
477
609
  /**
478
 
   *  @class  ThermostatFluxFiltered
479
 
   *  @brief  Class enforces GLC on atomic forces based on FE power when using fractional step time integration
 
610
   *  @class  ThermostatIntegratorFluxFiltered
 
611
   *  @brief  Class integrates GLC on atomic forces based on FE power when using fractional step time integration
480
612
   *          in conjunction with time filtering
481
613
   */
482
614
 
483
 
  class ThermostatFluxFiltered : public ThermostatFlux {
 
615
  class ThermostatIntegratorFluxFiltered : public ThermostatIntegratorFlux {
484
616
  
485
617
  public:
486
618
  
487
 
    ThermostatFluxFiltered(Thermostat * thermostat,
488
 
                           const std::string & regulatorPrefix = "");
 
619
    ThermostatIntegratorFluxFiltered(AtomicRegulator * thermostat,
 
620
                                     int lambdaMaxIterations,
 
621
                                     const std::string & regulatorPrefix = "");
489
622
        
490
 
    virtual ~ThermostatFluxFiltered() {};
 
623
    virtual ~ThermostatIntegratorFluxFiltered() {};
491
624
 
492
625
    /** pre-run initialization of method data */
493
626
    virtual void initialize();
518
651
  private:
519
652
 
520
653
    // DO NOT define this
521
 
    ThermostatFluxFiltered();
 
654
    ThermostatIntegratorFluxFiltered();
522
655
 
523
656
  };
524
657
 
525
658
  /**
526
 
   *  @class  ThermostatFixedFiltered
 
659
   *  @class  ThermostatIntegratorFixedFiltered
527
660
   *  @brief  Class for thermostatting using the temperature matching constraint and is compatible with
528
661
 the fractional step time-integration with time filtering
529
662
   */
530
663
  
531
 
  class ThermostatFixedFiltered : public ThermostatFixed {
 
664
  class ThermostatIntegratorFixedFiltered : public ThermostatIntegratorFixed {
532
665
  
533
666
  public:
534
667
  
535
 
    ThermostatFixedFiltered(Thermostat * thermostat,
536
 
                            const std::string & regulatorPrefix = "");
 
668
    ThermostatIntegratorFixedFiltered(AtomicRegulator * thermostat,
 
669
                                      int lambdaMaxIterations,
 
670
                                      const std::string & regulatorPrefix = "");
537
671
        
538
 
    virtual ~ThermostatFixedFiltered() {};
 
672
    virtual ~ThermostatIntegratorFixedFiltered() {};
539
673
 
540
674
    /** get data for output */
541
675
    virtual void output(OUTPUT_LIST & outputData);
561
695
  private:
562
696
 
563
697
    // DO NOT define this
564
 
    ThermostatFixedFiltered();
 
698
    ThermostatIntegratorFixedFiltered();
565
699
 
566
700
  };
567
701
 
574
708
 
575
709
  public:
576
710
 
577
 
    ThermostatFluxFixed(Thermostat * thermostat,
 
711
    ThermostatFluxFixed(AtomicRegulator * thermostat,
 
712
                        int lambdaMaxIterations,
578
713
                        bool constructThermostats = true);
579
714
        
580
715
    virtual ~ThermostatFluxFixed();
605
740
 
606
741
    // data
607
742
    /** thermostat for imposing the fluxes */
608
 
    ThermostatFlux * thermostatFlux_;
 
743
    ThermostatIntegratorFlux * thermostatFlux_;
609
744
 
610
745
    /** thermostat for imposing fixed nodes */
611
 
    ThermostatFixed * thermostatFixed_;
 
746
    ThermostatIntegratorFixed * thermostatFixed_;
612
747
 
613
748
    /** pointer to whichever thermostat should compute the flux, based on coupling method */
614
749
    ThermostatGlcFs * thermostatBcs_;
628
763
 
629
764
  public:
630
765
 
631
 
    ThermostatFluxFixedFiltered(Thermostat * thermostat);
 
766
    ThermostatFluxFixedFiltered(AtomicRegulator * thermostat,
 
767
                                int lambdaMaxIterations);
632
768
        
633
769
    virtual ~ThermostatFluxFixedFiltered(){};
634
770
 
648
784
  
649
785
  public:
650
786
  
651
 
    ThermostatGlc(Thermostat * thermostat);
 
787
    ThermostatGlc(AtomicRegulator * thermostat);
652
788
        
653
789
    virtual ~ThermostatGlc() {};
654
790
 
699
835
  
700
836
  public:
701
837
 
702
 
    ThermostatPowerVerlet(Thermostat * thermostat);
 
838
    ThermostatPowerVerlet(AtomicRegulator * thermostat);
703
839
        
704
840
    virtual ~ThermostatPowerVerlet() {};
705
841
 
770
906
  
771
907
  public:
772
908
 
773
 
    ThermostatHooverVerlet(Thermostat * thermostat);
 
909
    ThermostatHooverVerlet(AtomicRegulator * thermostat);
774
910
        
775
911
    virtual ~ThermostatHooverVerlet() {};
776
912
 
825
961
  
826
962
  public:
827
963
 
828
 
    ThermostatPowerVerletFiltered(Thermostat * thermostat);
 
964
    ThermostatPowerVerletFiltered(AtomicRegulator * thermostat);
829
965
        
830
966
    virtual ~ThermostatPowerVerletFiltered(){};
831
967
 
875
1011
  
876
1012
  public:
877
1013
 
878
 
    ThermostatHooverVerletFiltered(Thermostat * thermostat);
 
1014
    ThermostatHooverVerletFiltered(AtomicRegulator * thermostat);
879
1015
        
880
1016
    virtual ~ThermostatHooverVerletFiltered() {};
881
1017