24 #include "../Atomicrex.h" 25 #include "../properties/FitProperty.h" 26 #include "../properties/DerivedProperty.h" 28 #include "../util/xml/XMLUtilities.h" 33 class AtomicStructure;
34 class DegreeOfFreedom;
67 if(name.empty() || find(_atomTypeNames.begin(), _atomTypeNames.end(),
name) != _atomTypeNames.end())
69 _atomTypeNames.push_back(name);
70 _atomTypeMasses.push_back(mass);
71 _atomTypeAtomicNumbers.push_back(atomicNumber);
72 _natomtypes = (int)_atomTypeNames.size();
78 BOOST_ASSERT(_natomtypes == _atomTypeNames.size());
79 BOOST_ASSERT(i >= 0 && i < _atomTypeNames.size());
80 return _atomTypeNames[i];
86 BOOST_ASSERT(_natomtypes == _atomTypeMasses.size());
87 BOOST_ASSERT(i >= 0 && i < _atomTypeMasses.size());
88 return _atomTypeMasses[i];
94 BOOST_ASSERT(_natomtypes == _atomTypeAtomicNumbers.size());
95 BOOST_ASSERT(i >= 0 && i < _atomTypeAtomicNumbers.size());
96 return _atomTypeAtomicNumbers[i];
101 auto iter = std::find(_atomTypeNames.begin(), _atomTypeNames.end(), s);
102 BOOST_ASSERT(iter != _atomTypeNames.end());
103 return iter - _atomTypeNames.begin();
110 const std::vector<Potential*>&
potentials()
const {
return _potentials; }
113 const std::vector<AtomicStructure*>&
structures()
const {
return _structures; }
152 auto d = _deformations.find(deformationId);
153 if(d != _deformations.end())
return &d->second;
190 void packDOF(
double* destination);
196 void packDOF(std::vector<double>& destination) {
274 void assignAbsoluteWeights();
305 void parsePotentialsElement(
XML::Element potentialsElement);
317 void parseDeformationsElement(
XML::Element deformationsElement);
329 std::vector<FPString> _atomTypeNames;
333 std::vector<double> _atomTypeMasses;
337 std::vector<int> _atomTypeAtomicNumbers;
340 double _maximumCutoff = 0.0;
343 std::vector<Potential*> _potentials;
349 std::vector<AtomicStructure*> _structures;
353 std::vector<AtomicStructure*> _referencedStructures;
357 std::vector<AtomicStructure*> _unreferencedStructures;
360 std::vector<DerivedProperty*> _derivedProperties;
363 std::vector<DegreeOfFreedom*> _completePotentialDOFList;
366 std::vector<DegreeOfFreedom*> _activePotentialDOFList;
370 size_t _numActiveDOF = 0;
373 std::vector<double> _currentState;
376 int _intervalForPrinting;
379 std::vector<FitProperty*> _propertyList;
382 std::shared_ptr<Minimizer> _fitMinimizer;
385 std::map<FPString, Matrix3> _deformations;
389 bool _potentialValidationEnabled =
false;
401 #include "../structures/AtomicStructure.h" 402 #include "../potentials/Potential.h" Base class for maintaining structures.
Definition: AtomicStructure.h:42
void parse(const FPString &file)
Parses the job description from the XML file.
Definition: FitJob.cpp:86
Definition: FitGroup.h:36
void addUnreferencedStructure(AtomicStructure *structure)
Add a structure to the list of unreferenced structures.
Definition: FitJob.h:127
bool addAtomType(const FPString &name, double mass=0.0, int atomicNumber=0)
Adds a new atom type to the job.
Definition: FitJob.h:66
double getDefaultPropertyTolerance(FitProperty *property)
Returns the default tolerance for the given property based on the selected tolerance preset...
Definition: FitJob.cpp:371
All tolerances are 1.0.
Definition: FitJob.h:43
int numAtomTypes() const
Returns the number of atom types used in this job.
Definition: FitJob.h:63
Indicates that the norm selected by the user should be used.
Definition: FitProperty.h:44
const std::vector< Potential * > & potentials() const
Returns the list of all potentials used in this job.
Definition: FitJob.h:110
void unpackDOF(const std::vector< double > &source)
Unpacks the values of all degrees of freedom from a linear vector.
Definition: FitJob.h:211
double maximumCutoff() const
Returns the maximum cutoff radius of all potentials used by this job.
Definition: FitJob.h:107
int atomTypeIndex(const FPString &s) const
Returns the index of the atom type.
Definition: FitJob.h:100
DerivedProperty * getDerivedProperty(const FPString &id)
Definition: FitJob.cpp:463
Specifies a balanced unit based assignment of tolerance parameters.
Definition: FitJob.h:44
FitJob()
Constructor.
Definition: FitJob.cpp:49
void prepareFitting()
Prepares a list of all degrees of freedom and properties that are to be fitted.
Definition: Fitting.cpp:37
ScalarFitProperty * parseScalarFitPropertyAttribute(XML::Element element, const char *attributeName)
Returns the ScalarFitProperty specified in the given element attribute.
Definition: FitJob.cpp:401
Definition: DerivedProperty.h:38
void performFitting()
Performs the actual fitting by minimizing the residual.
Definition: Fitting.cpp:95
Definition: FitProperty.h:38
std::shared_ptr< Minimizer > fitMinimizer()
Returns the minimizer.
Definition: FitJob.h:161
void addReferencedStructure(AtomicStructure *structure)
Add a structure to the list of referenced structures.
Definition: FitJob.cpp:495
const std::vector< FitProperty * > & fitProperties()
Returns the global list of active properties which are included in the fit and which need to be compu...
Definition: FitJob.h:133
int parseAtomTypeElement(XML::Element element, const char *elementName)
Returns the atom type index of the species specified in the given element.
Definition: FitJob.cpp:326
double calculateResidual(FitProperty::ResidualNorm norm=FitProperty::UserDefined)
Calculates the total residual, i.e. the objective function to be minimized during fitting...
Definition: Fitting.cpp:248
ScalarFitProperty * getScalarFitProperty(const FPString &id)
Definition: FitJob.cpp:426
void printPotentialDOFList(bool printFullDOFList)
Outputs the current values of all DOFs of the potentials.
Definition: Fitting.cpp:170
Specifies a unit based assignment that emphasizes energies.
Definition: FitJob.h:45
This file collects the definition of classes that define various simple crystal structures.
Definition: Atomicrex.h:67
TolerancePreset
Specifies presets for tolerance parameters.
Definition: FitJob.h:42
std::vector< int > parseAtomTypesAttribute(XML::Element element, const char *attributeName)
Returns the list of atom types corresponding to the species specified in the given element attribute...
Definition: FitJob.cpp:340
FitGroup & rootGroup()
Returns the root node of the property group tree.
Definition: FitJob.h:136
std::string FPString
The default string type used throughout the code:
Definition: Atomicrex.h:70
const Matrix3 * lookupDeformation(const FPString &deformationId) const
Returns the deformation with the given id. Returns NULL if no such deformation has been defined...
Definition: FitJob.h:151
void printFittingProperties()
Outputs the list of properties being fitted.
Definition: Fitting.cpp:206
const std::vector< AtomicStructure * > & structures() const
Returns the list of all atomic structures used for fitting.
Definition: FitJob.h:113
bool fittingEnabled() const
Returns whether fitting will be performed.
Definition: FitJob.h:158
Definition: XMLUtilities.h:69
int atomTypeAtomicNumber(int i) const
Definition: FitJob.h:93
~FitJob()
Destructor.
Definition: FitJob.cpp:56
const FPString & atomTypeName(int i) const
Returns the name of the i-th atom type.
Definition: FitJob.h:77
const std::vector< AtomicStructure * > & unreferencedStructures() const
Definition: FitJob.h:124
void validatePotentials()
Performs a check of the energy/force calculation routines using numerical differentiation.
Definition: Validation.cpp:97
const std::vector< DerivedProperty * > & derivedProperties()
Returns the list of all derived properties.
Definition: FitJob.h:130
void packDOF(std::vector< double > &destination)
Packs the values of all degrees of freedom into a linear vector, which can be passed to the minimizer...
Definition: FitJob.h:196
const FPString & name() const
Returns the user-defined name of this job.
Definition: FitJob.h:57
AtomicStructure * getAtomicStructure(const FPString &id)
Definition: FitJob.cpp:451
Definition: FitProperty.h:126
int numActiveDOF() const
Returns the total number of active degrees of freedom.
Definition: FitJob.h:184
bool potentialValidationEnabled() const
Returns whether validation of the force/energy calculation routines has been requested by the user...
Definition: FitJob.h:178
int parseAtomTypeAttribute(XML::Element element, const char *attributeName)
Returns the atom type index of the species specified in the given element attribute.
Definition: FitJob.cpp:312
ResidualNorm
Specifies how residual contributions are calculated.
Definition: FitProperty.h:43
void unpackDOF(const double *source)
Unpacks the values of all degrees of freedom from a linear vector.
Definition: Fitting.cpp:236
double atomTypeMass(int i) const
Definition: FitJob.h:85
void packDOF(double *destination)
Packs the values of all degrees of freedom into a linear vector, which can be passed to the minimizer...
Definition: Fitting.cpp:226
const std::vector< AtomicStructure * > & referencedStructures() const
Definition: FitJob.h:117