Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spherical harmonics nn #43

Merged
merged 78 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
4674881
added new ansatz
ScSteffen Jan 2, 2023
3dd9fcb
debug new ansatz
ScSteffen Jan 21, 2023
ab9c2eb
branch should be abandoned here
ScSteffen Jan 21, 2023
6012c77
debug new ansatz
ScSteffen Jan 21, 2023
9e6285a
fix scaling error new ansatz
ScSteffen Jan 21, 2023
3b013b6
fix config errors
ScSteffen Jan 24, 2023
7a38d73
temporarily fixed dynamic ansatz rotation bug
Jan 24, 2023
d28e974
fix inheritance error for new ansatz
ScSteffen Jan 27, 2023
2bdf065
mesh acceleration
Feb 16, 2023
270561a
Merge branch 'new_ansatz_reg' of github.com:CSMMLab/KiT-RT into new_a…
Feb 16, 2023
ca5a372
add structured hohlraum
ScSteffen Mar 6, 2023
2b4453a
Merge branch 'new_ansatz_reg' of github.com:CSMMLab/KiT-RT into new_a…
ScSteffen Mar 6, 2023
95f6a5a
added spherical harmonics basis generator
Mar 11, 2023
5e1c367
parallelize datagen
Mar 11, 2023
9a2fb8b
added flag for dynamic ansatz
Mar 13, 2023
5f71821
added rotated monomial basis
Mar 13, 2023
155424d
fixed compilation errors
Mar 13, 2023
4f19806
fixed rotated basis linesource
Mar 14, 2023
b26d22c
added rotated hohlraum testcase
ScSteffen Mar 14, 2023
45e814c
code cleanup
Mar 14, 2023
1c147a0
restructure old files
Mar 14, 2023
4c0b462
added regularized monomial m1 networks
Mar 24, 2023
9ec9e88
Merge branch 'spherical_harmonics_nn' of github.com:CSMMLab/KiT-RT in…
Mar 24, 2023
55e1f4d
added spherical harmonics inference and started tests on rotation
Mar 25, 2023
fd84ddc
added sh models
Mar 26, 2023
5b600da
merged
Mar 26, 2023
f535ea3
added rotated sh networks
Mar 26, 2023
33c78b1
beautifier
Mar 26, 2023
7788d7f
merged develop into branch
Mar 27, 2023
e3eceb6
added rotated sh 2d and 3d models. EXPERIMENTALLY
Mar 29, 2023
a07e615
re-add mirroring
Apr 3, 2023
0fea941
did dynamic ansatz after rotation
Apr 3, 2023
4f06122
added symmetry correction
Apr 4, 2023
d96101c
fixed 2d sh projection
Apr 12, 2023
1671d00
merge from cloud
Apr 12, 2023
5a2f627
added 2d sh to datagenerator
Jun 5, 2023
e7ef214
remove rotation from data-gen
Jun 5, 2023
4612df7
update 2d mn solver
Jun 5, 2023
eda0656
delete redundant logs
Jun 5, 2023
d88c431
add rotation to 2d data-gen
Jun 5, 2023
79bc062
removed debugging output
Jun 5, 2023
a5a2aa5
parallelize sampler again
Jun 5, 2023
bc7d3d4
added 2d sh rotator up do degree 4
Jun 6, 2023
21a147a
fixed rotation matrix
Jun 11, 2023
762efaf
test run for sh2d rotated m1 closure
Jun 12, 2023
de69474
fix compile error
ScSteffen Jun 12, 2023
32aadec
attempt to fix vector size bug
Jun 12, 2023
6c66526
add option to turn of rotation
Jun 12, 2023
f16aea2
change m1_2d model
Jun 12, 2023
36f6ad3
change m1_2d models
Jun 14, 2023
69e03a4
delete tf history files
ScSteffen Jun 14, 2023
56f3f72
Merge branch 'spherical_harmonics_nn' of github.com:CSMMLab/KiT-RT in…
Jun 14, 2023
cc2ab1e
bugfix: u_2 was manually set to 0 in 2d sh network evaluation - remov…
Jun 14, 2023
b0b83e9
bugfix: dynamic closure was missing in non-rotated 2d monomial and sh…
Jun 14, 2023
8395eb1
bugfix: false naming of 2d m1 sh model
Jun 14, 2023
aae8f66
bugfix: vector length for rotated sh neural network closure
Jun 14, 2023
c208c28
renamed some vectors
Jun 14, 2023
8407dc9
fix: formatting, BUGFIX: rotation angle
ScSteffen Jun 20, 2023
c16364d
bugfix: made several function arguments in optimizer const for type s…
Jun 20, 2023
a96456f
enhance: made rotated datagen mirrored
Jun 20, 2023
01b8555
ongoing: fix rotated mn bug for spherical harmonics
Jun 20, 2023
5fb64f3
bufgfix: Rotated m1 works now
Jun 21, 2023
bde754c
enhance: rotated m1 models added
Jun 21, 2023
f7b352e
bugfix: removed column deletion for higher order rotated models
Jun 22, 2023
e1b65ee
formatting
ScSteffen Jun 23, 2023
e764a43
modelchange: m1_2d_rot
Jun 23, 2023
6527ee0
Merge branch 'spherical_harmonics_nn' of github.com:CSMMLab/KiT-RT in…
Jun 23, 2023
bed6f85
change: dockerfile
ScSteffen Jun 23, 2023
6758ee2
Merge branch 'spherical_harmonics_nn' of github.com:CSMMLab/KiT-RT in…
ScSteffen Jun 23, 2023
0a90635
enhance: added sh m2 models. change: newton optimizer stopping criter…
Jul 4, 2023
b0e4cd8
merge
Jul 4, 2023
f265e75
change: default values for newton
Jul 4, 2023
cf85009
change: changed error measure of neural cells to relative norm error
ScSteffen Jul 4, 2023
33bc7a4
enhance: add M3 spherical harmonics models
Jul 5, 2023
17b9d0a
added measure for inaccuraate nn cells
ScSteffen Jul 6, 2023
fa9a8d7
Merge branch 'develop' into spherical_harmonics_nn
ScSteffen Nov 14, 2023
d8e7451
enabled M3 rotations
Dec 31, 2023
3afdac1
merge from develop
Dec 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/optimizers/neuralnetworkoptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,19 @@ NeuralNetworkOptimizer::NeuralNetworkOptimizer( Config* settings ) : OptimizerBa
_tfModel = new cppflow::model( tfModelPath ); // load model
unsigned servingSize = _settings->GetNCells();
if( _settings->GetEnforceNeuralRotationalSymmetry() ) {
if( _settings->GetMaxMomentDegree() > 2 ) {
if( _settings->GetMaxMomentDegree() > 3 ) {
ErrorMessages::Error( "This postprocessing step is currently only for M1 and M2 models available.", CURRENT_FUNCTION );
}
servingSize *= 2; // Double number of vectors, since we mirror the rotated vector
_rotationMats.resize( _settings->GetNCells() );
_rotationMatsT.resize( _settings->GetNCells() );
}

if (_settings->GetMaxMomentDegree() == 1 && _settings->GetDim() ==2 && _settings->GetEnforceNeuralRotationalSymmetry()){
if( _settings->GetMaxMomentDegree() == 1 && _settings->GetDim() == 2 && _settings->GetEnforceNeuralRotationalSymmetry() ) {
_modelServingVectorU.resize( servingSize * ( _nSystem - 2 ) ); // reserve size for model servitor
}
else
{
_modelServingVectorU.resize( servingSize * ( _nSystem - 1 ) ); // reserve size for model servitor
else {
_modelServingVectorU.resize( servingSize * ( _nSystem - 1 ) ); // reserve size for model servitor
}
// Specify model input name
// Call Model (change call depending on model mk) (Seems to be randomly assigned by tensorflow)
Expand Down Expand Up @@ -367,7 +366,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
}
servingSize *= 2;
}
else { // No Preprocessing
else { // No Postprocessing
#pragma omp parallel for
for( unsigned idx_cell = 0; idx_cell < _settings->GetNCells(); idx_cell++ ) {
for( unsigned idx_sys = 0; idx_sys < _nSystem - 1; idx_sys++ ) {
Expand Down Expand Up @@ -402,6 +401,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
// Mirror order 1 Moments
alphaRedMirror[idx_sys] =
-1 * (double)_modelServingVectorAlpha[( _settings->GetNCells() + idx_cell ) * ( _nSystem - 1 ) + idx_sys];

alphaRed[idx_sys] = ( alphaRed[idx_sys] + alphaRedMirror[idx_sys] ) / 2; // average (and store in alphaRed)
// alphaCorr[idx_sys+1] = alphaRed[idx_sys];
}
Expand Down Expand Up @@ -460,6 +460,7 @@ void NeuralNetworkOptimizer::InferenceMonomial( VectorVector& alpha, const Vecto
}
alphaRed[idx_sys] = ( alphaRed[idx_sys] + alphaRedMirror[idx_sys] ) / 2; // average (and store in alphaRed)
}
alpha_norms[idx_cell] = norm( alphaRed ) * norm( alphaRed );

// Rotate Back
Vector alpha1{ alphaRed[0], alphaRed[1] };
Expand Down Expand Up @@ -594,7 +595,7 @@ void NeuralNetworkOptimizer::InferenceSphericalHarmonics2D( VectorVector& alpha,
Vector alphaTempFull = Vector( _nSystem, 0.0 ); // local reduced mirrored alpha (with dummy entry at 0)
Vector alphaTempMirror = Vector( _nSystem, 0.0 ); // local reduced mirrored alpha (with dummy entry at 0)

if( _settings->GetMaxMomentDegree() == 1 ) { // Using this
if( _settings->GetMaxMomentDegree() == 1 ) { // Using this
for( unsigned idx_sys = 0; idx_sys < _nSystem - 2; idx_sys++ ) {
alphaTempFull[idx_sys + 1] = (double)_modelServingVectorAlpha[idx_cell * ( _nSystem - 2 ) + idx_sys];
alphaTempMirror[idx_sys + 1] =
Expand Down Expand Up @@ -754,7 +755,7 @@ void NeuralNetworkOptimizer::InferenceSphericalHarmonics( VectorVector& alpha,
alpha_P_Mirror[idx_sys + 1] = (double)_modelServingVectorAlpha[( _settings->GetNCells() + idx_cell ) * ( _nSystem - 1 ) + idx_sys];
}
alpha_P_Mirror = rot180 * alpha_P_Mirror;
alpha[idx_cell] = ( alphaP + alpha_P_Mirror ) / 2; // average (and store in alpha)
alpha[idx_cell] = ( alphaP + alpha_P_Mirror ) / 2; // average (and store in alpha)

alpha[idx_cell] = _rotationMatsT[idx_cell] * alpha[idx_cell]; // Rotate back
// alpha[idx_cell][2] = 0.0; //manually enforce slab geometry
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/docker_run_interactive_specify_cores.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker run -i -t --rm --cpuset-cpus=0-12 -v $(pwd)/../..:/mnt kitrt/test_ml:latest /bin/bash
docker run -i -t --rm --cpuset-cpus=0-23 -v $(pwd)/../..:/mnt kitrt/test_ml:latest /bin/bash
Loading