Added potential energy error term in addition to the displacement error term
This commit is contained in:
parent
534efb98bb
commit
eaad6cb308
|
|
@ -153,7 +153,9 @@ int main(int argc, char *argv[])
|
||||||
csv_resultsLocalFile << endrow;
|
csv_resultsLocalFile << endrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReducedModelEvaluator::evaluateReducedModel(optimizationResults);
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
|
|
||||||
std::vector<std::string> scenarioLabels(
|
std::vector<std::string> scenarioLabels(
|
||||||
optimizationResults.objectiveValue.perSimulationScenario_total.size());
|
optimizationResults.objectiveValue.perSimulationScenario_total.size());
|
||||||
const double colorAxial = 1;
|
const double colorAxial = 1;
|
||||||
|
|
@ -161,7 +163,8 @@ int main(int argc, char *argv[])
|
||||||
const double colorBending = 5;
|
const double colorBending = 5;
|
||||||
const double colorDome = 0.1;
|
const double colorDome = 0.1;
|
||||||
const double colorSaddle = 0;
|
const double colorSaddle = 0;
|
||||||
std::vector<double> colors(optimizationResults.objectiveValue.perSimulationScenario_total.size());
|
std::vector<double> colors(
|
||||||
|
optimizationResults.objectiveValue.perSimulationScenario_total.size());
|
||||||
for (int scenarioIndex = 0; scenarioIndex < scenarioLabels.size(); scenarioIndex++) {
|
for (int scenarioIndex = 0; scenarioIndex < scenarioLabels.size(); scenarioIndex++) {
|
||||||
scenarioLabels[scenarioIndex]
|
scenarioLabels[scenarioIndex]
|
||||||
= optimizationResults.reducedPatternSimulationJobs[scenarioIndex]->getLabel();
|
= optimizationResults.reducedPatternSimulationJobs[scenarioIndex]->getLabel();
|
||||||
|
|
@ -187,7 +190,8 @@ int main(int argc, char *argv[])
|
||||||
y[scenarioIndex]
|
y[scenarioIndex]
|
||||||
// = optimizationResults.objectiveValue.perSimulationScenario_rawTranslational[scenarioIndex]
|
// = optimizationResults.objectiveValue.perSimulationScenario_rawTranslational[scenarioIndex]
|
||||||
// + optimizationResults.objectiveValue.perSimulationScenario_rawRotational[scenarioIndex];
|
// + optimizationResults.objectiveValue.perSimulationScenario_rawRotational[scenarioIndex];
|
||||||
= optimizationResults.objectiveValue.perSimulationScenario_total_unweighted[scenarioIndex];
|
= optimizationResults.objectiveValue
|
||||||
|
.perSimulationScenario_total_unweighted[scenarioIndex];
|
||||||
}
|
}
|
||||||
std::vector<double> x = matplot::linspace(0, y.size() - 1, y.size());
|
std::vector<double> x = matplot::linspace(0, y.size() - 1, y.size());
|
||||||
std::vector<double> markerSizes(y.size(), 5);
|
std::vector<double> markerSizes(y.size(), 5);
|
||||||
|
|
@ -206,7 +210,6 @@ int main(int argc, char *argv[])
|
||||||
// ReducedModelOptimization::Results optResults;
|
// ReducedModelOptimization::Results optResults;
|
||||||
// optResults.load("/home/iason/Desktop/dlib_ensmallen_comparison/TestSets/"
|
// optResults.load("/home/iason/Desktop/dlib_ensmallen_comparison/TestSets/"
|
||||||
// "singlePattern_dlib_firstSubmission/12@single_reduced(100000_1.20)");
|
// "singlePattern_dlib_firstSubmission/12@single_reduced(100000_1.20)");
|
||||||
ReducedModelEvaluator::evaluateReducedModel(optimizationResults);
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,9 +108,9 @@ double ReducedModelOptimizer::computeRawRotationalError(
|
||||||
{
|
{
|
||||||
double rawRotationalError = 0;
|
double rawRotationalError = 0;
|
||||||
for (const auto &reducedToFullInterfaceViPair : reducedToFullInterfaceViMap) {
|
for (const auto &reducedToFullInterfaceViPair : reducedToFullInterfaceViMap) {
|
||||||
const double vertexRotationalError
|
const double vertexRotationalError = std::abs(
|
||||||
= rotatedQuaternion_fullPattern[reducedToFullInterfaceViPair.second].angularDistance(
|
rotatedQuaternion_fullPattern[reducedToFullInterfaceViPair.second].angularDistance(
|
||||||
rotatedQuaternion_reducedPattern[reducedToFullInterfaceViPair.first]);
|
rotatedQuaternion_reducedPattern[reducedToFullInterfaceViPair.first]));
|
||||||
rawRotationalError += vertexRotationalError;
|
rawRotationalError += vertexRotationalError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ double ReducedModelOptimizer::objective(const std::vector<double> &x)
|
||||||
// FormFinder simulator;
|
// FormFinder simulator;
|
||||||
|
|
||||||
std::for_each(
|
std::for_each(
|
||||||
std::execution::par_unseq,
|
// std::execution::par_unseq,
|
||||||
global.simulationScenarioIndices.begin(),
|
global.simulationScenarioIndices.begin(),
|
||||||
global.simulationScenarioIndices.end(),
|
global.simulationScenarioIndices.end(),
|
||||||
[&](const int &simulationScenarioIndex) {
|
[&](const int &simulationScenarioIndex) {
|
||||||
|
|
@ -267,15 +267,11 @@ double ReducedModelOptimizer::objective(const std::vector<double> &x)
|
||||||
std::cout << "Failed simulation" << std::endl;
|
std::cout << "Failed simulation" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// double simulationScenarioError = 0;
|
const double simulationScenarioError_PE = std::abs(
|
||||||
// constexpr bool usePotentialEnergy = false;
|
(reducedModelResults.internalPotentialEnergy
|
||||||
// if (usePotentialEnergy) {
|
- global.fullPatternResults[simulationScenarioIndex].internalPotentialEnergy)
|
||||||
// simulationScenarioError += std::abs(
|
/ global.fullPatternResults[simulationScenarioIndex].internalPotentialEnergy);
|
||||||
// reducedModelResults.internalPotentialEnergy
|
// else {
|
||||||
// - global.fullPatternResults[simulationScenarioIndex].internalPotentialEnergy
|
|
||||||
// / global.fullPatternResults[simulationScenarioIndex]
|
|
||||||
// .internalPotentialEnergy);
|
|
||||||
// } else {
|
|
||||||
#ifdef POLYSCOPE_DEFINED
|
#ifdef POLYSCOPE_DEFINED
|
||||||
#ifdef USE_SCENARIO_WEIGHTS
|
#ifdef USE_SCENARIO_WEIGHTS
|
||||||
const double scenarioWeight = global.scenarioWeights[simulationScenarioIndex];
|
const double scenarioWeight = global.scenarioWeights[simulationScenarioIndex];
|
||||||
|
|
@ -285,7 +281,7 @@ double ReducedModelOptimizer::objective(const std::vector<double> &x)
|
||||||
#else
|
#else
|
||||||
const double scenarioWeight = 1;
|
const double scenarioWeight = 1;
|
||||||
#endif
|
#endif
|
||||||
const double simulationScenarioError = computeError(
|
const double simulationScenarioError_displacements = computeError(
|
||||||
global.fullPatternResults[simulationScenarioIndex],
|
global.fullPatternResults[simulationScenarioIndex],
|
||||||
reducedModelResults,
|
reducedModelResults,
|
||||||
global.reducedToFullInterfaceViMap,
|
global.reducedToFullInterfaceViMap,
|
||||||
|
|
@ -294,7 +290,8 @@ double ReducedModelOptimizer::objective(const std::vector<double> &x)
|
||||||
scenarioWeight,
|
scenarioWeight,
|
||||||
global.objectiveWeights[simulationScenarioIndex]);
|
global.objectiveWeights[simulationScenarioIndex]);
|
||||||
|
|
||||||
simulationErrorsPerScenario[simulationScenarioIndex] = simulationScenarioError;
|
simulationErrorsPerScenario[simulationScenarioIndex]
|
||||||
|
= simulationScenarioError_displacements + simulationScenarioError_PE;
|
||||||
// }
|
// }
|
||||||
// #ifdef POLYSCOPE_DEFINED
|
// #ifdef POLYSCOPE_DEFINED
|
||||||
// reducedJob->pMesh->registerForDrawing(Colors::reducedInitial);
|
// reducedJob->pMesh->registerForDrawing(Colors::reducedInitial);
|
||||||
|
|
@ -978,7 +975,8 @@ ReducedModelOptimizer::getFullPatternMaxSimulationForces(
|
||||||
.append(m_pFullPatternSimulationMesh->getLabel() + ".json"));
|
.append(m_pFullPatternSimulationMesh->getLabel() + ".json"));
|
||||||
const bool fullPatternScenarioMagnitudesExist = std::filesystem::exists(
|
const bool fullPatternScenarioMagnitudesExist = std::filesystem::exists(
|
||||||
patternMaxForceMagnitudesFilePath);
|
patternMaxForceMagnitudesFilePath);
|
||||||
if (fullPatternScenarioMagnitudesExist) {
|
constexpr bool recomputeMagnitudes = false;
|
||||||
|
if (fullPatternScenarioMagnitudesExist && !recomputeMagnitudes) {
|
||||||
nlohmann::json json;
|
nlohmann::json json;
|
||||||
std::ifstream ifs(patternMaxForceMagnitudesFilePath.string());
|
std::ifstream ifs(patternMaxForceMagnitudesFilePath.string());
|
||||||
ifs >> json;
|
ifs >> json;
|
||||||
|
|
@ -1798,9 +1796,9 @@ void ReducedModelOptimizer::computeObjectiveValueNormalizationFactors()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
angularDistanceSum += global.fullPatternResults[simulationScenarioIndex]
|
angularDistanceSum += std::abs(global.fullPatternResults[simulationScenarioIndex]
|
||||||
.rotationalDisplacementQuaternion[fullPatternVi]
|
.rotationalDisplacementQuaternion[fullPatternVi]
|
||||||
.angularDistance(Eigen::Quaterniond::Identity());
|
.angularDistance(Eigen::Quaterniond::Identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fullPatternTranslationalDisplacementNormSum[simulationScenarioIndex]
|
fullPatternTranslationalDisplacementNormSum[simulationScenarioIndex]
|
||||||
|
|
@ -1916,7 +1914,7 @@ void ReducedModelOptimizer::optimize(
|
||||||
.append(m_pFullPatternSimulationMesh->getLabel())
|
.append(m_pFullPatternSimulationMesh->getLabel())
|
||||||
.append(pFullPatternSimulationJob->getLabel()));
|
.append(pFullPatternSimulationJob->getLabel()));
|
||||||
// .append(pFullPatternSimulationJob->getLabel() + ".json")
|
// .append(pFullPatternSimulationJob->getLabel() + ".json")
|
||||||
constexpr bool recomputeFullPatternResults = false;
|
constexpr bool recomputeFullPatternResults = true;
|
||||||
SimulationResults fullPatternResults;
|
SimulationResults fullPatternResults;
|
||||||
if (!recomputeFullPatternResults && std::filesystem::exists(jobResultsDirectoryPath)) {
|
if (!recomputeFullPatternResults && std::filesystem::exists(jobResultsDirectoryPath)) {
|
||||||
fullPatternResults.load(std::filesystem::path(jobResultsDirectoryPath).append("Results"),
|
fullPatternResults.load(std::filesystem::path(jobResultsDirectoryPath).append("Results"),
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
// inline constexpr static ParameterLabels parameterLabels();
|
// inline constexpr static ParameterLabels parameterLabels();
|
||||||
|
|
||||||
inline static std::array<std::string, ReducedModelOptimization::NumberOfOptimizationVariables>
|
inline static std::array<std::string, ReducedModelOptimization::NumberOfOptimizationVariables>
|
||||||
parameterLabels = {"R", "A", "I2", "I3", "J", "Theta", "R"};
|
parameterLabels = {"E", "A", "I2", "I3", "J", "Theta", "R"};
|
||||||
constexpr static std::array<double, ReducedModelOptimization::NumberOfBaseSimulationScenarios>
|
constexpr static std::array<double, ReducedModelOptimization::NumberOfBaseSimulationScenarios>
|
||||||
simulationScenariosResolution = {11, 11, 20, 20, 20};
|
simulationScenariosResolution = {11, 11, 20, 20, 20};
|
||||||
constexpr static std::array<double, ReducedModelOptimization::NumberOfBaseSimulationScenarios>
|
constexpr static std::array<double, ReducedModelOptimization::NumberOfBaseSimulationScenarios>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue