File: ThermalTimeIntegrator.cpp

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (698 lines) | stat: -rw-r--r-- 28,930 bytes parent folder | download | duplicates (2)
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
// ATC transfer headers
#include "ThermalTimeIntegrator.h"
#include "TransferOperator.h"
#include "ATC_Coupling.h"
#include "TimeFilter.h"
#include "ATC_Error.h"
#include "PerAtomQuantityLibrary.h"

namespace ATC {

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalTimeIntegrator
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //--------------------------------------------------------
  ThermalTimeIntegrator::ThermalTimeIntegrator(ATC_Coupling * atc,
                                               TimeIntegrationType timeIntegrationType) :
    TimeIntegrator(atc, timeIntegrationType)
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  modify
  //    parses inputs and modifies state of the integrator
  //--------------------------------------------------------
  bool ThermalTimeIntegrator::modify(int /* narg */, char **arg)
  {
    bool foundMatch = false;
    int argIndex = 0;

    // time integration scheme
    /*! \page man_thermal_time_integration fix_modify AtC time_integration (thermal)
      \section syntax
      fix_modify AtC time_integration <descriptor> \n
      - descriptor (string) = time integration type  \n

      various time integration methods for the finite elements\n
      \section description
      gear - atomic velocity update with 2nd order Verlet, nodal temperature update with 3rd or 4th order Gear, thermostats based on controlling power \n
      fractional_step - atomic velocity update with 2nd order Verlet, mixed nodal temperature update, 3/4 Gear for continuum and 2 Verlet for atomic contributions, thermostats based on controlling discrete energy changes\n
      \section examples
      <TT> fix_modify atc time_integration gear </TT> \n
      <TT> fix_modify atc time_integration fractional_step </TT> \n
      \section description
      \section related
      see \ref man_fix_atc
      \section default
      none
    */
    if (strcmp(arg[argIndex],"gear")==0) {
      timeIntegrationType_ = GEAR;
      needReset_ = true;
      foundMatch = true;
    }
    else if (strcmp(arg[argIndex],"fractional_step")==0) {
      timeIntegrationType_ = FRACTIONAL_STEP;
      needReset_ = true;
      foundMatch = true;
    }
    return foundMatch;
  }

  //--------------------------------------------------------
  //  construct_methods
  //    creates algorithm objects
  //--------------------------------------------------------
  void ThermalTimeIntegrator::construct_methods()
  {
    if (atc_->reset_methods()) {
      if (timeIntegrationMethod_) delete timeIntegrationMethod_;

      if (timeFilterManager_->need_reset()) {
        switch (timeIntegrationType_) {
          case GEAR: {
            timeFilter_ = timeFilterManager_->construct(TimeFilterManager::IMPLICIT);
            atc_->set_mass_mat_time_filter(TEMPERATURE,TimeFilterManager::EXPLICIT);
            break;
          }
          case FRACTIONAL_STEP: {
            timeFilter_ = timeFilterManager_->construct(TimeFilterManager::EXPLICIT_IMPLICIT);
            atc_->set_mass_mat_time_filter(TEMPERATURE,TimeFilterManager::EXPLICIT_IMPLICIT);
            break;
          }
          default:
            throw ATC_Error("Unknown time integration type in ThermalTimeIntegrator::Initialize()");
        }
      }

      if (timeFilterManager_->filter_dynamics()) {
        switch (timeIntegrationType_) {
          case GEAR: {
            timeIntegrationMethod_ = new ThermalTimeIntegratorGearFiltered(this);
            break;
          }
          case FRACTIONAL_STEP: {
            timeIntegrationMethod_ = new ThermalTimeIntegratorFractionalStepFiltered(this);
            break;
          }
        default:
          throw ATC_Error("Unknown time integration type in ThermalTimeIntegrator::Initialize()");
        }
      }
      else {
        switch (timeIntegrationType_) {
          case GEAR: {
            timeIntegrationMethod_ = new ThermalTimeIntegratorGear(this);
            break;
          }
          case FRACTIONAL_STEP: {
            timeIntegrationMethod_ = new ThermalTimeIntegratorFractionalStep(this);
            break;
          }
        default:
          throw ATC_Error("Unknown time integration type in ThermalTimeIntegrator::Initialize()");
        }
      }
    }
  }

  //--------------------------------------------------------
  //  pack_fields
  //    add persistent variables to data list
  //--------------------------------------------------------
  void ThermalTimeIntegrator::pack_fields(RESTART_LIST & data)
  {
    data["NodalAtomicPowerFiltered"] = & nodalAtomicPowerFiltered_.set_quantity();
    data["NodalAtomicEnergyFiltered"] = & nodalAtomicEnergyFiltered_.set_quantity();
    TimeIntegrator::pack_fields(data);
  }

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalIntegrationMethod
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //        Grab data from ATC
  //--------------------------------------------------------
  ThermalIntegrationMethod::ThermalIntegrationMethod(ThermalTimeIntegrator * thermalTimeIntegrator) :
    TimeIntegrationMethod(thermalTimeIntegrator),
    timeFilter_(thermalTimeIntegrator->time_filter()),
    temperature_(atc_->field(TEMPERATURE)),
    temperatureRoc_(atc_->field_roc(TEMPERATURE)),
    temperature2Roc_(atc_->field_2roc(TEMPERATURE)),
    nodalAtomicTemperatureOut_(atc_->nodal_atomic_field(TEMPERATURE)),
    nodalAtomicTemperature_(nullptr),
    temperatureRhs_(atc_->field_rhs(TEMPERATURE)),
    nodalAtomicPowerOut_(atc_->nodal_atomic_field_roc(TEMPERATURE))
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  construct_transfers
  //        Grab existing managed quantities,
  //        create the rest
  //--------------------------------------------------------
  void ThermalIntegrationMethod::construct_transfers()
  {
    nodalAtomicTemperature_ =
      (atc_->interscale_manager()).dense_matrix("NodalAtomicTemperature");
  }

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalIntegratorGear
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //--------------------------------------------------------
  ThermalTimeIntegratorGear::ThermalTimeIntegratorGear(ThermalTimeIntegrator * thermalTimeIntegrator) :
    ThermalIntegrationMethod(thermalTimeIntegrator),
    nodalAtomicPowerFiltered_(thermalTimeIntegrator->nodal_atomic_power_filtered())
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  construct_transfers
  //        Grab existing managed quantities,
  //        create the rest
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::construct_transfers()
  {
    ThermalIntegrationMethod::construct_transfers();
    InterscaleManager & interscaleManager = atc_->interscale_manager();

    // add in power computation
    DotTwiceKineticEnergy * dotTwiceKineticEnergy =
      new DotTwiceKineticEnergy(atc_);
    interscaleManager.add_per_atom_quantity(dotTwiceKineticEnergy,"DotTwiceKineticEnergy");
    nodalAtomicPower_ = new AtfShapeFunctionRestriction(atc_,
                                                        dotTwiceKineticEnergy,
                                                        interscaleManager.per_atom_sparse_matrix("Interpolant"));
    interscaleManager.add_dense_matrix(nodalAtomicPower_,"NodalAtomicPower");
  }

  //--------------------------------------------------------
  //  initialize
  //        initialize all data
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::initialize()
  {
    ThermalIntegrationMethod::initialize();

    // sets up time filter for cases where variables temporally filtered
    // this time integrator should use an implicit filter
    TimeFilterManager * timeFilterManager = atc_->time_filter_manager();
    if (timeFilterManager->need_reset()) {
      // Some time filters need the old value for the power
      timeFilter_->initialize(nodalAtomicPower_->quantity());
    }

    if (!timeFilterManager->end_equilibrate()) {
      nodalAtomicPowerFiltered_.reset(atc_->num_nodes(),1);
    }

    if (!timeFilterManager->filter_dynamics()) {
      temperatureRhs_ = nodalAtomicPower_->quantity();
    }
  }

  //--------------------------------------------------------
  //  pre_initial_integrate2
  ///   time integration before Verlet step 1
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::pre_initial_integrate2(double dt)
  {
    // Predict nodal temperatures and time derivatives based on FE data
    // use 3rd order Gear
    gear1_3_predict(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.quantity(),dt);
  }

  //--------------------------------------------------------
  //  post_final_integrate1
  //    time integration after Verlet step 2
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::post_final_integrate1(double dt)
  {
    const DENS_MAT & myNodalAtomicPower(nodalAtomicPower_->quantity());
    timeFilter_->apply_post_step2(nodalAtomicPowerFiltered_.set_quantity(),
                                  myNodalAtomicPower,dt);
    temperatureRhs_ += myNodalAtomicPower;

    // Finish updating temperature
    _temperatureResidual_.resize(atc_->num_nodes(),1);
    atc_->apply_inverse_mass_matrix(temperatureRhs_.quantity(),
                                    _temperatureResidual_,
                                    TEMPERATURE);
    _temperatureResidual_ -= temperatureRoc_.quantity();
    _temperatureResidual_ *= dt;

    gear1_3_correct(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    _temperatureResidual_,dt);
  }

  //--------------------------------------------------------
  //  post_process
  //    do any post-processing calculations required for
  //    output phase
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::post_process()
  {
    nodalAtomicPowerOut_ = nodalAtomicPower_->quantity();
    nodalAtomicTemperatureOut_ = nodalAtomicTemperature_->quantity();
  }

  //--------------------------------------------------------
  //  finish
  //    finalize state of nodal atomic quantities
  //--------------------------------------------------------
  void ThermalTimeIntegratorGear::finish()
  {
    post_process();
  }

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalTimeIntegratorGearFiltered
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //        Grab data from ATC
  //--------------------------------------------------------

  ThermalTimeIntegratorGearFiltered::ThermalTimeIntegratorGearFiltered(ThermalTimeIntegrator * thermalTimeIntegrator) :
    ThermalTimeIntegratorGear(thermalTimeIntegrator),
    temperature3Roc_(atc_->field_3roc(TEMPERATURE))
  {
    // do nothing

    //      specifically if history data is required and we need another time filter object for the fields
  }

  //--------------------------------------------------------
  //  pre_initial_integrate2
  //    time integration before Verlet step 1
  //--------------------------------------------------------
  void ThermalTimeIntegratorGearFiltered::pre_initial_integrate2(double dt)
  {
    // Predict nodal temperatures and time derivatives based on FE data
    // use 3rd order Gear
    gear1_4_predict(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    temperature3Roc_.quantity(),dt);
  }

  //--------------------------------------------------------
  //  post_final_integrate1
  //    first time integration computations
  //    after Verlet step 2
  //--------------------------------------------------------
  void ThermalTimeIntegratorGearFiltered::post_final_integrate1(double dt)
  {
    DENS_MAT & myNodalAtomicPowerFiltered(nodalAtomicPowerFiltered_.set_quantity());
    timeFilter_->apply_post_step2(myNodalAtomicPowerFiltered,nodalAtomicPower_->quantity(),dt);
    temperatureRhs_ += myNodalAtomicPowerFiltered;

    // Finish updating temperature
    _temperatureResidual_.resize(atc_->num_nodes(),1);
    atc_->apply_inverse_mass_matrix(temperatureRhs_.quantity(),
                                            _temperatureResidual_,
                                            TEMPERATURE);
    _temperatureResidual_ -= temperatureRoc_.quantity();
    _temperatureResidual_ *= dt;
    gear1_4_correct(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    temperature3Roc_.set_quantity(),
                    _temperatureResidual_,dt);
  }

  //--------------------------------------------------------
  //  post_final_integrate3
  //    third time integration computations
  //    after Verlet step 2
  //--------------------------------------------------------
  void ThermalTimeIntegratorGearFiltered::post_final_integrate3(double dt)
  {
    // update filtered atomic temperature
    timeFilter_->apply_post_step2(nodalAtomicTemperatureOut_.set_quantity(),
                                  nodalAtomicTemperature_->quantity(),dt);
  }

  //--------------------------------------------------------
  //  post_process
  //    do any post-processing calculations required for
  //    output phase
  //--------------------------------------------------------
  void ThermalTimeIntegratorGearFiltered::post_process()
  {
    nodalAtomicPowerOut_ = nodalAtomicPowerFiltered_.quantity();
  }

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalIntegratorFractionalStep
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //        Grab data from ATC
  //--------------------------------------------------------

  ThermalTimeIntegratorFractionalStep::ThermalTimeIntegratorFractionalStep(ThermalTimeIntegrator * thermalTimeIntegrator) :
    ThermalIntegrationMethod(thermalTimeIntegrator),
    nodalAtomicEnergyFiltered_(thermalTimeIntegrator->nodal_atomic_energy_filtered()),
    nodalAtomicPowerFiltered_(thermalTimeIntegrator->nodal_atomic_power_filtered()),
    atomicTemperatureDelta_(atc_->num_nodes(),1),
    nodalAtomicEnergy_(nullptr),
    nodalAtomicEnergyOld_(atc_->num_nodes(),1),
    nodalAtomicTemperatureOld_(atc_->num_nodes(),1)
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  construct_transfers
  //        Grab existing managed quantities,
  //        create the rest
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::construct_transfers()
  {
    ThermalIntegrationMethod::construct_transfers();
    InterscaleManager & interscaleManager(atc_->interscale_manager());
    nodalAtomicEnergy_ = interscaleManager.dense_matrix("NodalAtomicEnergy");
  }

  //--------------------------------------------------------
  //  initialize
  //        initialize all data
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::initialize()
  {
    ThermalIntegrationMethod::initialize();

    // initial power to zero
    nodalAtomicPower_.reset(atc_->num_nodes(),1);

    // sets up time filter for cases where variables temporally filtered
    // this time integrator should use Crank-Nicholson filter for 2nd order accuracy
    TimeFilterManager * timeFilterManager = atc_->time_filter_manager();
    if (timeFilterManager->need_reset()) {
      // the form of this integrator implies no time filters that require history data can be used
      timeFilter_->initialize();
    }

    // sets up time filter for post-processing the filtered power
    // this time integrator should use an explicit-implicit filter
    // to mirror the 2nd order Verlet integration scheme
    // It requires no history information so initial value just sizes arrays
    if (!timeFilterManager->end_equilibrate()) {
      // implies an initial condition of the instantaneous atomic energy
      // for the corresponding filtered variable, consistent with the temperature
      nodalAtomicEnergyFiltered_ = nodalAtomicEnergy_->quantity();
      nodalAtomicPowerFiltered_.reset(atc_->num_nodes(),1);
    }
  }

  //--------------------------------------------------------
  //  pre_initial_integrate1
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::pre_initial_integrate1(double dt)
  {
    const DENS_MAT & myNodalAtomicEnergy(nodalAtomicEnergy_->quantity());
    // updated filtered energy using explicit-implicit scheme
    timeFilter_->apply_pre_step1(nodalAtomicEnergyFiltered_.set_quantity(),
                                 myNodalAtomicEnergy,dt);
  }

  //--------------------------------------------------------
  //  pre_initial_integrate2
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::pre_initial_integrate2(double dt)
  {
    // used for updating change in temperature from mass matrix change
    this->compute_old_time_data();

    // update FE contributions
    apply_gear_predictor(dt);

    // update filtered nodal atomic power

    //      that way thermostat and integrator can be consistent
    timeFilter_->apply_pre_step1(nodalAtomicPowerFiltered_.set_quantity(),
                                 nodalAtomicPower_,dt);

    // store current energy for use later
    nodalAtomicPower_ = nodalAtomicEnergy_->quantity();
    nodalAtomicPower_ *= -1.;
  }

  //--------------------------------------------------------
  //  pre_final_integrate1
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::pre_final_integrate1(double dt)
  {

    //      before the new rhs is computed but after atomic velocity is updated
    //      to allow for general notions of temperature beyond kinetic.
    // compute change in restricted atomic energy
    nodalAtomicPower_ += nodalAtomicEnergy_->quantity();

    // update FE temperature with change in temperature from MD
    compute_temperature_delta(nodalAtomicPower_,dt);
    temperature_ += atomicTemperatureDelta_.quantity();

    // approximation to power for output
    nodalAtomicPower_ /= dt;
    timeFilter_->apply_post_step1(nodalAtomicPowerFiltered_.set_quantity(),
                                  nodalAtomicPower_,dt);

    // make sure nodes are fixed
    atc_->set_fixed_nodes();
  }

  //--------------------------------------------------------
  //  post_final_integrate1
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::post_final_integrate1(double dt)
  {
    // Finish updating temperature with FE contributions
    atc_->apply_inverse_mass_matrix(temperatureRhs_.quantity(),
                                    _temperatureResidual_,TEMPERATURE);
    _temperatureResidual_ -= temperatureRoc_.quantity();
    _temperatureResidual_ *= dt;
    apply_gear_corrector(_temperatureResidual_,dt);
  }

  //--------------------------------------------------------
  //  post_final_integrate3
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::post_final_integrate3(double dt)
  {
    // update filtered atomic energy
    timeFilter_->apply_post_step1(nodalAtomicEnergyFiltered_.set_quantity(),
                                  nodalAtomicEnergy_->quantity(),dt);
  }

  //--------------------------------------------------------
  //  output
  //    add variables to output list
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::post_process()
  {
    nodalAtomicPowerOut_ = nodalAtomicPower_;
    nodalAtomicTemperatureOut_ = nodalAtomicTemperature_->quantity();
  }

  //--------------------------------------------------------
  //  finish
  //    finalize state of nodal atomic quantities
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::finish()
  {
    post_process();
  }

  //--------------------------------------------------------
  //  apply_gear_predictor
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::apply_gear_predictor(double dt)
  {
    gear1_3_predict(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.quantity(),dt);
  }

  //--------------------------------------------------------
  //  apply_gear_corrector
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::apply_gear_corrector(const DENS_MAT & R_theta, double dt)
  {
    gear1_3_correct(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    R_theta,dt);
  }

  //--------------------------------------------------------
  //  compute_old_time_data
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::compute_old_time_data()
  {
    const DENS_MAT & myNodalAtomicEnergy(nodalAtomicEnergy_->quantity());
    atc_->apply_inverse_mass_matrix(myNodalAtomicEnergy,
                                    nodalAtomicTemperatureOld_.set_quantity(),
                                    TEMPERATURE);
    nodalAtomicEnergyOld_ = myNodalAtomicEnergy;
  }

  //--------------------------------------------------------
  //  compute_temperature_delta
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStep::compute_temperature_delta(const DENS_MAT & atomicEnergyDelta,
                                                                      double /* dt */)
  {
    DENS_MAT & myAtomicTemperatureDelta(atomicTemperatureDelta_.set_quantity());
    myAtomicTemperatureDelta = nodalAtomicEnergyOld_.quantity() + atomicEnergyDelta;
    atc_->apply_inverse_mass_matrix(myAtomicTemperatureDelta,
                                    TEMPERATURE);
    myAtomicTemperatureDelta += -1.*(nodalAtomicTemperatureOld_.quantity());
  }

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ThermalTimeIntegratorFracionalStepFiltered
  //--------------------------------------------------------
  //--------------------------------------------------------

  //--------------------------------------------------------
  //  Constructor
  //        Grab data from ATC
  //--------------------------------------------------------

  ThermalTimeIntegratorFractionalStepFiltered::ThermalTimeIntegratorFractionalStepFiltered(ThermalTimeIntegrator * thermalTimeIntegrator) :
    ThermalTimeIntegratorFractionalStep(thermalTimeIntegrator),
    temperature3Roc_(atc_->field_3roc(TEMPERATURE))
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  Destructor
  //--------------------------------------------------------
  ThermalTimeIntegratorFractionalStepFiltered::~ThermalTimeIntegratorFractionalStepFiltered()
  {
    // do nothing
  }

  //--------------------------------------------------------
  //  pre_initial_integrate1
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::pre_initial_integrate1(double dt)
  {
    // determine change in temperature if no forces were applied over this timestep

    // relevant coefficients from time filter
    double coefF1 = timeFilter_->filtered_coefficient_pre_s1(dt);
    double coefF2 = timeFilter_->filtered_coefficient_post_s1(dt);
    double coefU1 = timeFilter_->unfiltered_coefficient_pre_s1(dt);
    double coefU2 = timeFilter_->unfiltered_coefficient_post_s1(dt);

    DENS_MAT & myAtomicTemperatureDelta(atomicTemperatureDelta_.set_quantity());
    DENS_MAT & myNodalAtomicEnergyFiltered(nodalAtomicEnergyFiltered_.set_quantity());
    const DENS_MAT & myNodalAtomicEnergy(nodalAtomicEnergy_->quantity());

    // composite from change after two step update of current filtered energy
    myAtomicTemperatureDelta = (coefF1*coefF2-1.)*myNodalAtomicEnergyFiltered;
    // change in filtered temperature from current energy from this and next time levels
    myAtomicTemperatureDelta += (coefU1*coefF2+coefU2)*myNodalAtomicEnergy;

    // updated filtered energy using explicit-implicit scheme
    // nodalAtomicEnergy_ is either set from initialization or from the end of the last timestep
    timeFilter_->apply_pre_step1(myNodalAtomicEnergyFiltered,myNodalAtomicEnergy,dt);
  }

  //--------------------------------------------------------
  //  output
  //    add variables to output list
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::output(OUTPUT_LIST & outputData)
  {
    atc_->apply_inverse_md_mass_matrix(nodalAtomicEnergyFiltered_.quantity(),
                                       nodalAtomicTemperatureOut_.set_quantity(),
                                       TEMPERATURE);
    DENS_MAT & nodalAtomicPower(nodalAtomicPowerFiltered_.set_quantity());
    if ((atc_->lammps_interface())->rank_zero()) {
      outputData["NodalAtomicPower"] = &nodalAtomicPower;
    }
  }

  //--------------------------------------------------------
  //  apply_gear_predictor
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::apply_gear_predictor(double dt)
  {
    gear1_4_predict(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    temperature3Roc_.quantity(),dt);
  }

  //--------------------------------------------------------
  //  apply_gear_corrector
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::apply_gear_corrector(const DENS_MAT & R_theta, double dt)
  {
    gear1_4_correct(temperature_.set_quantity(),
                    temperatureRoc_.set_quantity(),
                    temperature2Roc_.set_quantity(),
                    temperature3Roc_.set_quantity(),
                    R_theta,dt);
  }

  //--------------------------------------------------------
  //  compute_temperature_delta
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::compute_old_time_data()
  {
    const DENS_MAT & myNodalAtomicEnergyFiltered(nodalAtomicEnergyFiltered_.quantity());
    atc_->apply_inverse_mass_matrix(myNodalAtomicEnergyFiltered,
                                    nodalAtomicTemperatureOld_.set_quantity(),
                                    TEMPERATURE);
    nodalAtomicEnergyOld_ = myNodalAtomicEnergyFiltered;
  }

  //--------------------------------------------------------
  //  compute_old_time_data
  //--------------------------------------------------------
  void ThermalTimeIntegratorFractionalStepFiltered::compute_temperature_delta(const DENS_MAT & atomicEnergyDelta,
                                                                              double dt)
  {
    DENS_MAT & myAtomicTemperatureDelta(atomicTemperatureDelta_.set_quantity());
    double coefU2 = timeFilter_->unfiltered_coefficient_post_s1(dt);
    myAtomicTemperatureDelta += nodalAtomicEnergyOld_.quantity() + coefU2*atomicEnergyDelta;
    atc_->apply_inverse_mass_matrix(myAtomicTemperatureDelta,
                                    TEMPERATURE);
    myAtomicTemperatureDelta += -1.*nodalAtomicTemperatureOld_.quantity();
  }
};