-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
persistent changes in parameters + variable nLayer
Changes made by master students from Université de Lorraine: Joseph Schlesinger & Mathis Georgel
- Loading branch information
David Jourdan
committed
Jun 25, 2024
1 parent
6e74cdb
commit 5543cae
Showing
7 changed files
with
144 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#pragma once | ||
|
||
const int nLayers = 10; | ||
const double layerHeight = 0.08; | ||
const double spacing = 0.4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "save.h" | ||
|
||
#include <fstream> | ||
#include <nlohmann/json.hpp> | ||
|
||
// Function to update and save advanced parameters to a JSON file | ||
void updateAndSaveAdvancedParams(double lambda1, double lambda2, double thickness, double deltaLambda, int n_layers, int n_iter, double lim) { | ||
// Create a JSON object to store advanced parameters | ||
nlohmann::json advancedParams; | ||
advancedParams["lambda1"] = lambda1; | ||
advancedParams["lambda2"] = lambda2; | ||
advancedParams["thickness"] = thickness; | ||
advancedParams["deltaLambda"] = deltaLambda; | ||
advancedParams["n_layers"] = n_layers; | ||
advancedParams["n_iter"] = n_iter; | ||
advancedParams["lim"] = lim; | ||
|
||
// Serialize JSON to file | ||
std::ofstream outputFile("advanced_params.json"); | ||
outputFile << advancedParams.dump(4); // dump with indentation for readability | ||
outputFile.close(); | ||
} | ||
|
||
// Function to load advanced parameters from a JSON file | ||
void loadAdvancedParams(double& lambda1, double& lambda2, double& thickness, double& deltaLambda, int& n_layers, int& n_iter, double& lim) { | ||
// Read the JSON file | ||
std::ifstream inputFile("advanced_params.json"); | ||
if (!inputFile.is_open()) { | ||
// Material data | ||
lambda1 = 0.58; | ||
lambda2 = 1.08; | ||
thickness = 1.218; | ||
deltaLambda = 0.0226764665509417; | ||
n_layers = 10; | ||
lim = 1e-6; | ||
n_iter = 1000; | ||
return; | ||
} | ||
|
||
// Parse JSON from file | ||
nlohmann::json advancedParams; | ||
inputFile >> advancedParams; | ||
|
||
// Extract parameters from JSON | ||
lambda1 = advancedParams["lambda1"]; | ||
lambda2 = advancedParams["lambda2"]; | ||
thickness = advancedParams["thickness"]; | ||
deltaLambda = advancedParams["deltaLambda"]; | ||
n_layers = advancedParams["n_layers"]; | ||
n_iter = advancedParams["n_iter"]; | ||
lim = advancedParams["lim"]; | ||
|
||
// Close the file | ||
inputFile.close(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
// Function to update and save advanced parameters to a JSON file | ||
void updateAndSaveAdvancedParams(double lambda1, double lambda2, double thickness, double deltaLambda, int n_layers, int n_iter, double lim); | ||
|
||
// Function to load advanced parameters from a JSON file | ||
void loadAdvancedParams(double& lambda1, double& lambda2, double& thickness, double& deltaLambda, int& n_layers, int& n_iter, double& lim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
length = 150 | ||
width = 20 | ||
nb_layers = 10 | ||
layer_height = 0.08 | ||
jump_y = width+10 | ||
jump_x = 0 | ||
shift_y = 2 * jump_y | ||
shift_x = 0 | ||
|
||
with open("sample.path", "w") as file: | ||
nb_layers = 9 | ||
layer_height = 0.08 | ||
for j in range(5): | ||
z = 0 | ||
for i in range(nb_layers): | ||
z += layer_height + i / (nb_layers - 1) * 2 * (0.8 / nb_layers - 0.08) | ||
y = -width/2 -j*jump_y + shift_y | ||
x = -length/2 + shift_x | ||
while(y < width/2 - j*jump_y + shift_y): | ||
if x < 0 + shift_x: | ||
file.write("2\n") | ||
file.write(f"{x:.2f} {y:.2f} {z:.4f}\n") | ||
x = length/2 + shift_x | ||
file.write(f"{x:.2f} {y:.2f} {z:.4f}\n") | ||
else: | ||
file.write("2\n") | ||
file.write(f"{x:.2f} {y:.2f} {z:.4f}\n") | ||
x = -length/2 + shift_x | ||
file.write(f"{x:.2f} {y:.2f} {z:.4f}\n") | ||
# y += 0.3 + i / (nb_layers - 1) * 0.5 | ||
y += 0.4 | ||
print(f"{z:.4f}") |