Continuum Membrane 719025a62b1e384a6ff80e2f2a223ef4012153dc
Loading...
Searching...
No Matches
Model.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <ctime>
14#include <random>
15
17#include "mesh/Mesh.hpp"
18#include "model/Model.hpp"
19#include "model/Record.hpp"
20#include "Parameters.hpp"
22
32{
33public:
34 bool usingNCG = false;
35 bool isNCGstuck = false;
36 bool usingRpi = false;
37 bool isCriteriaSatisfied = false;
38 double trialStepSize = 0.0;
40 double c1 = 1e-6;
41 double c2 = 0.001;
42 double stepThreshold = 1e-15;
45 double energyDiffThreshold = 1e-5;
46 double forceDiffThreshold = 1e-4;
47
55
64 const double c1,
65 const double c2,
66 const double stepThreshold);
67
74
88};
89
93class Model
94{
95public:
97 {
98 int iteration = 0;
99 double temperatureKelvin = 0.0;
100 double kBT = 0.0;
101 double deltaEnergy = 0.0;
103 bool accepted = false;
104 };
105
106 // Geometry, energy, and force
109 // Optimization
111 double stepSize;
113 std::vector<Force> ncgDirection0;
114
115 // Simulated Annealing
116 bool isHeating = true;
118 int coolingStep = 35;
120 int heatingStep = 15;
121 double highTemperature = 0.0;
122 std::mt19937 thermalRng;
124 std::vector<ThermalFluctuationRecord> thermalFluctuationRecords;
125
132 Model(Mesh &mesh_, Record &record_);
133
146
155
163
173
179
180 // energy and force
190
196 bool simulated_annealing_next_step(bool forceAttempt = false);
197
203
209};
The Force class defines corresponding force terms type. Note that all the forces are gsl matrices wit...
This file defines mesh class containing a vector of vertices and a vector of faces that are required ...
Contains the Model class, which encapsulates a mesh and a record object.
This file defines essential parameters used in continuum membrane as well as membrane dynamics code....
A class representing a triangular mesh that defines a limit surface.
Definition Mesh.hpp:54
The Model class encapsulates a Mesh and a Record object.
Definition Model.hpp:94
void update_ncg_direction()
Updates the direction for nonlinear conjugate gradient (NCG) optimization.
void update_vertex_using_NCG()
Update vertex coordinates using a non-linear conjugate gradient method.
std::string to_string_current_step()
Returns a string representation of the current step's iteration number, trial step size,...
int currentHeatingStep
Definition Model.hpp:119
OptimizationAlgorithm oa
Definition Model.hpp:112
double stepSize
Definition Model.hpp:111
std::vector< Force > ncgDirection0
vector to store the initial direction for nonlinear conjugate gradient optimization
Definition Model.hpp:113
std::vector< ThermalFluctuationRecord > thermalFluctuationRecords
Diagnostics for thermal trial moves.
Definition Model.hpp:124
bool simulated_annealing_next_step(bool forceAttempt=false)
Use a Metropolis thermal trial move to sample beyond local gradient descent.
double linear_search_for_stepsize_to_minimize_energy()
Performs a linear search to find the optimal step size that minimizes energy using either nonlinear c...
int currentCoolingStep
Definition Model.hpp:117
Mesh & mesh
Definition Model.hpp:107
bool isHeating
Definition Model.hpp:116
bool should_continue_optimization()
Determines whether the optimization algorithm should continue running.
int thermalFluctuationAttemptCount
Number of attempted thermal trial moves.
Definition Model.hpp:123
std::mt19937 thermalRng
Reproducible random generator for thermal fluctuation trial moves.
Definition Model.hpp:122
Model(Mesh &mesh_, Record &record_)
Constructs a new Model object.
int heatingStep
Definition Model.hpp:120
int coolingStep
Definition Model.hpp:118
void enforce_boundary_conditions_after_coordinate_update()
Synchronize boundary/ghost coordinates after direct coordinate updates.
double highTemperature
Definition Model.hpp:121
void reset_ncg_direction()
Reset the direction for nonlinear conjugate gradient (NCG) optimization.
void determine_trial_step_size()
This code determines the step size used in an optimization algorithm. The step size is used to calcul...
Record & record
Definition Model.hpp:108
int iteration
Definition Model.hpp:110
A class that defines an optimization algorithm and its settings. This class defines the settings for ...
Definition Model.hpp:32
OptimizationAlgorithm()
Constructor for the OptimizationAlgorithm class.
int nConsecutiveNcgStuckThreshold
The threshold of consecutive NCG stuck iterations before disabling it.
Definition Model.hpp:44
bool usingNCG
Flag indicating whether to use the nonlinear conjugate gradient optimizer.
Definition Model.hpp:34
double c2
The c2 parameter in the NCG Wolfe condition.
Definition Model.hpp:41
bool isNCGstuck
Flag indicating whether the NCG optimizer has gotten stuck and cannot further minimize.
Definition Model.hpp:35
bool disable_NCG_if_stuck_consecutively()
Disables the use of NCG if it has been stuck consecutively over a threshold.
double energyDiffThreshold
The energy difference threshold for convergence checking.
Definition Model.hpp:45
double c1
The c1 parameter in the NCG Wolfe condition.
Definition Model.hpp:40
double trialStepSize
The step size used in the optimization algorithm.
Definition Model.hpp:38
int nConsecutiveNcgStuck
The number of consecutive times the NCG optimizer has gotten stuck.
Definition Model.hpp:43
double stepThreshold
The lower bound for the step size in NCG.
Definition Model.hpp:42
double forceDiffThreshold
The mean force difference threshold for convergence checking.
Definition Model.hpp:46
void reset_NCG_Rpi()
Reset NCG and Rpi to default.
bool isCriteriaSatisfied
Flag indicating whether the optimization criteria have been met.
Definition Model.hpp:37
bool usingRpi
Flag indicating whether to use the R-pi adaptive method for regularization energy.
Definition Model.hpp:36
OptimizationAlgorithm(const int trialIterationInterval, const double c1, const double c2, const double stepThreshold)
Constructor for the OptimizationAlgorithm class.
int trialIterationInterval
The number of iterations between trial step size adjustments.
Definition Model.hpp:39
Bookkeeps simulation data throughout iterations.
Definition Record.hpp:13
Definition Model.hpp:97
int iteration
Definition Model.hpp:98
bool accepted
Definition Model.hpp:103
double temperatureKelvin
Definition Model.hpp:99
double deltaEnergy
Definition Model.hpp:101
double acceptanceProbability
Definition Model.hpp:102
double kBT
Definition Model.hpp:100