Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
0f72fceb
Commit
0f72fceb
authored
Jul 16, 2020
by
steffen.schotthoefer
Browse files
removed unneccesary python files, added fct to mn solver to extract NN training data
parent
796bfdd0
Pipeline
#98358
passed with stages
in 38 minutes and 46 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
code/build/debug_tests/.gitkeep
0 → 100644
View file @
0f72fceb
code/build/release_tests/.gitkeep
0 → 100644
View file @
0f72fceb
code/include/solvers/mnsolver.h
View file @
0f72fceb
...
...
@@ -28,22 +28,35 @@ class MNSolver : public Solver
unsigned
_nTotalEntries
;
/*! @brief: Total number of equations in the system */
unsigned
short
_nMaxMomentsOrder
;
/*! @brief: Max Order of Moments */
VectorVector
_sigmaA
;
/*! @brief: Absorption coefficient for all energies*/
// Solver specific physics
VectorVector
_sigmaA
;
/*! @brief: Absorption coefficient for all energies*/
// Moment basis
SphericalHarmonics
*
_basis
;
/*! @brief: Class to compute and store current spherical harmonics basis */
VectorVector
_moments
;
/*! @brief: Moment Vector pre-computed at each quadrature point: dim= _nq x _nTotalEntries */
// Right hand side members
Vector
_scatterMatDiag
;
/*! @brief: Diagonal of the scattering matrix (its a diagonal matrix by construction) */
// TODO: Source
// quadrature related
nu
mbers
// quadrature related
me
mbers
VectorVector
_quadPoints
;
/*! @brief quadrature points, dim(_quadPoints) = (_nq,spatialDim) */
Vector
_weights
;
/*! @brief quadrature weights, dim(_weights) = (_nq) */
VectorVector
_quadPointsSphere
;
/*! @brief (my,phi), dim(_quadPoints) = (_nq,2) */
Entropy
Base
*
_entropy
;
/*! @brief: Class to handle entropy functionals */
VectorVector
_alpha
;
/*! @brief: Lagrange Multipliers for Minimal Entropy problem for each gridCell
Layout: _nCells x _nTot
alEntr
ies*/
//
Entropy
Optimization related members
EntropyBase
*
_entropy
;
/*! @brief: Class to handle entropy functionals */
VectorVector
_alpha
;
/*! @brief: Lagrange Multipliers for Minim
al
Entr
opy problem for each gridCell
Layout: _nCells x _nTotalEntries*/
OptimizerBase
*
_optimizer
;
/*! @brief: Class to solve minimal entropy problem */
// Output related members
std
::
vector
<
std
::
vector
<
double
>>
_outputFields
;
/*! @brief: Protoype output */
/*! @brief Function that writes NN Training Data in a .csv file */
void
WriteNNTrainingData
(
unsigned
idx_pseudoTime
);
// Member functions
/*! @brief : computes the global index of the moment corresponding to basis function (l,k)
* @param : degree l, it must hold: 0 <= l <=_nq
* @param : order k, it must hold: -l <=k <= l
...
...
code/python/AssLegendrePlotter.m
deleted
100644 → 0
View file @
796bfdd0
clear;
clc;
filename = 'assLegendre.csv';
M = csvread(filename);
[nPts, nMom] =size(M);
for i =2: nMom
plot(M(:,1),M(:,i))
hold on;
end
legend("0,0" , "1,0" , "1,1", "2,0" , "2,1" , "2,2" )
\ No newline at end of file
code/python/assLegendre.csv
deleted
100644 → 0
View file @
796bfdd0
-1,0.398942,-0.690988,-0,0.892062,0,0
-0.99,0.398942,-0.684078,-0.0689259,0.865434,0.152582,0.0108709
-0.98,0.398942,-0.677169,-0.0972307,0.839074,0.213066,0.0216325
-0.97,0.398942,-0.670259,-0.118782,0.812981,0.257636,0.0322848
-0.96,0.398942,-0.663349,-0.136809,0.787156,0.293677,0.0428279
-0.95,0.398942,-0.656439,-0.152566,0.761598,0.324091,0.0532617
-0.94,0.398942,-0.649529,-0.166699,0.736308,0.350385,0.0635863
-0.93,0.398942,-0.642619,-0.179591,0.711286,0.373466,0.0738016
-0.92,0.398942,-0.635709,-0.191492,0.686531,0.393935,0.0839077
-0.91,0.398942,-0.628799,-0.202579,0.662044,0.412211,0.0939045
-0.9,0.398942,-0.621889,-0.212977,0.637824,0.428608,0.103792
-0.89,0.398942,-0.61498,-0.222783,0.613873,0.443361,0.11357
-0.88,0.398942,-0.60807,-0.232073,0.590188,0.45666,0.123239
-0.87,0.398942,-0.60116,-0.240906,0.566772,0.468654,0.132799
-0.86,0.398942,-0.59425,-0.249331,0.543623,0.479468,0.14225
-0.85,0.398942,-0.58734,-0.257387,0.520741,0.489205,0.151591
-0.84,0.398942,-0.58043,-0.265109,0.498127,0.497954,0.160823
-0.83,0.398942,-0.57352,-0.272525,0.475781,0.505788,0.169946
-0.82,0.398942,-0.56661,-0.279658,0.453703,0.512775,0.178959
-0.81,0.398942,-0.559701,-0.286531,0.431892,0.518969,0.187864
-0.8,0.398942,-0.552791,-0.293162,0.410349,0.524423,0.196659
-0.79,0.398942,-0.545881,-0.299566,0.389073,0.529181,0.205344
-0.78,0.398942,-0.538971,-0.305757,0.368065,0.533282,0.213921
-0.77,0.398942,-0.532061,-0.31175,0.347324,0.536762,0.222388
-0.76,0.398942,-0.525151,-0.317554,0.326852,0.539655,0.230746
-0.75,0.398942,-0.518241,-0.32318,0.306646,0.54199,0.238995
-0.74,0.398942,-0.511331,-0.328637,0.286709,0.543793,0.247134
-0.73,0.398942,-0.504421,-0.333934,0.267039,0.54509,0.255165
-0.72,0.398942,-0.497512,-0.339077,0.247636,0.545904,0.263086
-0.71,0.398942,-0.490602,-0.344075,0.228502,0.546256,0.270897
-0.7,0.398942,-0.483692,-0.348932,0.209635,0.546165,0.2786
-0.69,0.398942,-0.476782,-0.353655,0.191035,0.54565,0.286193
-0.68,0.398942,-0.469872,-0.358249,0.172703,0.544727,0.293677
-0.67,0.398942,-0.462962,-0.362719,0.154639,0.543414,0.301052
-0.66,0.398942,-0.456052,-0.36707,0.136842,0.541724,0.308317
-0.65,0.398942,-0.449142,-0.371306,0.119313,0.539672,0.315473
-0.64,0.398942,-0.442233,-0.37543,0.102052,0.537272,0.32252
-0.63,0.398942,-0.435323,-0.379446,0.0850581,0.534535,0.329458
-0.62,0.398942,-0.428413,-0.383358,0.068332,0.531474,0.336286
-0.61,0.398942,-0.421503,-0.387169,0.0518734,0.5281,0.343006
-0.6,0.398942,-0.414593,-0.390882,0.0356825,0.524423,0.349615
-0.59,0.398942,-0.407683,-0.394499,0.0197592,0.520455,0.356116
-0.58,0.398942,-0.400773,-0.398024,0.00410349,0.516205,0.362508
-0.57,0.398942,-0.393863,-0.401458,-0.0112846,0.511681,0.36879
-0.56,0.398942,-0.386953,-0.404804,-0.026405,0.506894,0.374963
-0.55,0.398942,-0.380044,-0.408064,-0.0412579,0.501852,0.381026
-0.54,0.398942,-0.373134,-0.41124,-0.0558431,0.496562,0.386981
-0.53,0.398942,-0.366224,-0.414334,-0.0701607,0.491034,0.392826
-0.52,0.398942,-0.359314,-0.417348,-0.0842107,0.485273,0.398562
-0.51,0.398942,-0.352404,-0.420283,-0.097993,0.479289,0.404188
-0.5,0.398942,-0.345494,-0.423142,-0.111508,0.473087,0.409706
-0.49,0.398942,-0.338584,-0.425926,-0.124755,0.466675,0.415114
-0.48,0.398942,-0.331674,-0.428636,-0.137734,0.46006,0.420413
-0.47,0.398942,-0.324765,-0.431273,-0.150446,0.453247,0.425602
-0.46,0.398942,-0.317855,-0.433839,-0.162891,0.446243,0.430683
-0.45,0.398942,-0.310945,-0.436336,-0.175067,0.439055,0.435654
-0.44,0.398942,-0.304035,-0.438764,-0.186976,0.431687,0.440516
-0.43,0.398942,-0.297125,-0.441124,-0.198618,0.424145,0.445268
-0.42,0.398942,-0.290215,-0.443419,-0.209991,0.416436,0.449911
-0.41,0.398942,-0.283305,-0.445647,-0.221098,0.408564,0.454446
-0.4,0.398942,-0.276395,-0.447812,-0.231936,0.400535,0.45887
-0.39,0.398942,-0.269485,-0.449912,-0.242507,0.392354,0.463186
-0.38,0.398942,-0.262576,-0.451951,-0.25281,0.384025,0.467392
-0.37,0.398942,-0.255666,-0.453927,-0.262846,0.375555,0.471489
-0.36,0.398942,-0.248756,-0.455843,-0.272614,0.366946,0.475477
-0.35,0.398942,-0.241846,-0.457698,-0.282115,0.358206,0.479356
-0.34,0.398942,-0.234936,-0.459494,-0.291347,0.349337,0.483125
-0.33,0.398942,-0.228026,-0.461231,-0.300313,0.340344,0.486785
-0.32,0.398942,-0.221116,-0.462911,-0.30901,0.331232,0.490336
-0.31,0.398942,-0.214206,-0.464532,-0.31744,0.322005,0.493777
-0.3,0.398942,-0.207296,-0.466097,-0.325603,0.312667,0.49711
-0.29,0.398942,-0.200387,-0.467606,-0.333497,0.303223,0.500333
-0.28,0.398942,-0.193477,-0.469058,-0.341125,0.293677,0.503446
-0.27,0.398942,-0.186567,-0.470456,-0.348484,0.284032,0.506451
-0.26,0.398942,-0.179657,-0.471799,-0.355576,0.274293,0.509346
-0.25,0.398942,-0.172747,-0.473087,-0.3624,0.264464,0.512132
-0.24,0.398942,-0.165837,-0.474322,-0.368957,0.254548,0.514809
-0.23,0.398942,-0.158927,-0.475503,-0.375246,0.244549,0.517376
-0.22,0.398942,-0.152017,-0.476632,-0.381267,0.234472,0.519835
-0.21,0.398942,-0.145108,-0.477707,-0.387021,0.224319,0.522184
-0.2,0.398942,-0.138198,-0.478731,-0.392507,0.214095,0.524423
-0.19,0.398942,-0.131288,-0.479702,-0.397726,0.203803,0.526554
-0.18,0.398942,-0.124378,-0.480622,-0.402677,0.193447,0.528575
-0.17,0.398942,-0.117468,-0.48149,-0.40736,0.18303,0.530487
-0.16,0.398942,-0.110558,-0.482308,-0.411776,0.172556,0.53229
-0.15,0.398942,-0.103648,-0.483074,-0.415924,0.162028,0.533983
-0.14,0.398942,-0.0967384,-0.483791,-0.419804,0.15145,0.535567
-0.13,0.398942,-0.0898285,-0.484456,-0.423417,0.140826,0.537042
-0.12,0.398942,-0.0829186,-0.485072,-0.426762,0.130158,0.538408
-0.11,0.398942,-0.0760087,-0.485637,-0.42984,0.119451,0.539664
-0.1,0.398942,-0.0690988,-0.486153,-0.43265,0.108707,0.540811
-0.09,0.398942,-0.0621889,-0.48662,-0.435192,0.0979303,0.541849
-0.08,0.398942,-0.0552791,-0.487036,-0.437467,0.0871237,0.542778
-0.07,0.398942,-0.0483692,-0.487404,-0.439474,0.0762908,0.543597
-0.06,0.398942,-0.0414593,-0.487722,-0.441214,0.0654348,0.544308
-0.05,0.398942,-0.0345494,-0.487991,-0.442686,0.0545591,0.544909
-0.04,0.398942,-0.0276395,-0.488211,-0.44389,0.043667,0.5454
-0.03,0.398942,-0.0207296,-0.488383,-0.444827,0.0327617,0.545783
-0.02,0.398942,-0.0138198,-0.488505,-0.445496,0.0218466,0.546056
-0.01,0.398942,-0.00690988,-0.488578,-0.445897,0.0109249,0.54622
7.5287e-16,0.398942,5.20224e-16,-0.488603,-0.446031,-8.22547e-16,0.546274
0.01,0.398942,0.00690988,-0.488578,-0.445897,-0.0109249,0.54622
0.02,0.398942,0.0138198,-0.488505,-0.445496,-0.0218466,0.546056
0.03,0.398942,0.0207296,-0.488383,-0.444827,-0.0327617,0.545783
0.04,0.398942,0.0276395,-0.488211,-0.44389,-0.043667,0.5454
0.05,0.398942,0.0345494,-0.487991,-0.442686,-0.0545591,0.544909
0.06,0.398942,0.0414593,-0.487722,-0.441214,-0.0654348,0.544308
0.07,0.398942,0.0483692,-0.487404,-0.439474,-0.0762908,0.543597
0.08,0.398942,0.0552791,-0.487036,-0.437467,-0.0871237,0.542778
0.09,0.398942,0.0621889,-0.48662,-0.435192,-0.0979303,0.541849
0.1,0.398942,0.0690988,-0.486153,-0.43265,-0.108707,0.540811
0.11,0.398942,0.0760087,-0.485637,-0.42984,-0.119451,0.539664
0.12,0.398942,0.0829186,-0.485072,-0.426762,-0.130158,0.538408
0.13,0.398942,0.0898285,-0.484456,-0.423417,-0.140826,0.537042
0.14,0.398942,0.0967384,-0.483791,-0.419804,-0.15145,0.535567
0.15,0.398942,0.103648,-0.483074,-0.415924,-0.162028,0.533983
0.16,0.398942,0.110558,-0.482308,-0.411776,-0.172556,0.53229
0.17,0.398942,0.117468,-0.48149,-0.40736,-0.18303,0.530487
0.18,0.398942,0.124378,-0.480622,-0.402677,-0.193447,0.528575
0.19,0.398942,0.131288,-0.479702,-0.397726,-0.203803,0.526554
0.2,0.398942,0.138198,-0.478731,-0.392507,-0.214095,0.524423
0.21,0.398942,0.145108,-0.477707,-0.387021,-0.224319,0.522184
0.22,0.398942,0.152017,-0.476632,-0.381267,-0.234472,0.519835
0.23,0.398942,0.158927,-0.475503,-0.375246,-0.244549,0.517376
0.24,0.398942,0.165837,-0.474322,-0.368957,-0.254548,0.514809
0.25,0.398942,0.172747,-0.473087,-0.3624,-0.264464,0.512132
0.26,0.398942,0.179657,-0.471799,-0.355576,-0.274293,0.509346
0.27,0.398942,0.186567,-0.470456,-0.348484,-0.284032,0.506451
0.28,0.398942,0.193477,-0.469058,-0.341125,-0.293677,0.503446
0.29,0.398942,0.200387,-0.467606,-0.333497,-0.303223,0.500333
0.3,0.398942,0.207296,-0.466097,-0.325603,-0.312667,0.49711
0.31,0.398942,0.214206,-0.464532,-0.31744,-0.322005,0.493777
0.32,0.398942,0.221116,-0.462911,-0.30901,-0.331232,0.490336
0.33,0.398942,0.228026,-0.461231,-0.300313,-0.340344,0.486785
0.34,0.398942,0.234936,-0.459494,-0.291347,-0.349337,0.483125
0.35,0.398942,0.241846,-0.457698,-0.282115,-0.358206,0.479356
0.36,0.398942,0.248756,-0.455843,-0.272614,-0.366946,0.475477
0.37,0.398942,0.255666,-0.453927,-0.262846,-0.375555,0.471489
0.38,0.398942,0.262576,-0.451951,-0.25281,-0.384025,0.467392
0.39,0.398942,0.269485,-0.449912,-0.242507,-0.392354,0.463186
0.4,0.398942,0.276395,-0.447812,-0.231936,-0.400535,0.45887
0.41,0.398942,0.283305,-0.445647,-0.221098,-0.408564,0.454446
0.42,0.398942,0.290215,-0.443419,-0.209991,-0.416436,0.449911
0.43,0.398942,0.297125,-0.441124,-0.198618,-0.424145,0.445268
0.44,0.398942,0.304035,-0.438764,-0.186976,-0.431687,0.440516
0.45,0.398942,0.310945,-0.436336,-0.175067,-0.439055,0.435654
0.46,0.398942,0.317855,-0.433839,-0.162891,-0.446243,0.430683
0.47,0.398942,0.324765,-0.431273,-0.150446,-0.453247,0.425602
0.48,0.398942,0.331674,-0.428636,-0.137734,-0.46006,0.420413
0.49,0.398942,0.338584,-0.425926,-0.124755,-0.466675,0.415114
0.5,0.398942,0.345494,-0.423142,-0.111508,-0.473087,0.409706
0.51,0.398942,0.352404,-0.420283,-0.097993,-0.479289,0.404188
0.52,0.398942,0.359314,-0.417348,-0.0842107,-0.485273,0.398562
0.53,0.398942,0.366224,-0.414334,-0.0701607,-0.491034,0.392826
0.54,0.398942,0.373134,-0.41124,-0.0558431,-0.496562,0.386981
0.55,0.398942,0.380044,-0.408064,-0.0412579,-0.501852,0.381026
0.56,0.398942,0.386953,-0.404804,-0.026405,-0.506894,0.374963
0.57,0.398942,0.393863,-0.401458,-0.0112846,-0.511681,0.36879
0.58,0.398942,0.400773,-0.398024,0.00410349,-0.516205,0.362508
0.59,0.398942,0.407683,-0.394499,0.0197592,-0.520455,0.356116
0.6,0.398942,0.414593,-0.390882,0.0356825,-0.524423,0.349615
0.61,0.398942,0.421503,-0.387169,0.0518734,-0.5281,0.343006
0.62,0.398942,0.428413,-0.383358,0.068332,-0.531474,0.336286
0.63,0.398942,0.435323,-0.379446,0.0850581,-0.534535,0.329458
0.64,0.398942,0.442233,-0.37543,0.102052,-0.537272,0.32252
0.65,0.398942,0.449142,-0.371306,0.119313,-0.539672,0.315473
0.66,0.398942,0.456052,-0.36707,0.136842,-0.541724,0.308317
0.67,0.398942,0.462962,-0.362719,0.154639,-0.543414,0.301052
0.68,0.398942,0.469872,-0.358249,0.172703,-0.544727,0.293677
0.69,0.398942,0.476782,-0.353655,0.191035,-0.54565,0.286193
0.7,0.398942,0.483692,-0.348932,0.209635,-0.546165,0.2786
0.71,0.398942,0.490602,-0.344075,0.228502,-0.546256,0.270897
0.72,0.398942,0.497512,-0.339077,0.247636,-0.545904,0.263086
0.73,0.398942,0.504421,-0.333934,0.267039,-0.54509,0.255165
0.74,0.398942,0.511331,-0.328637,0.286709,-0.543793,0.247134
0.75,0.398942,0.518241,-0.32318,0.306646,-0.54199,0.238995
0.76,0.398942,0.525151,-0.317554,0.326852,-0.539655,0.230746
0.77,0.398942,0.532061,-0.31175,0.347324,-0.536762,0.222388
0.78,0.398942,0.538971,-0.305757,0.368065,-0.533282,0.213921
0.79,0.398942,0.545881,-0.299566,0.389073,-0.529181,0.205344
0.8,0.398942,0.552791,-0.293162,0.410349,-0.524423,0.196659
0.81,0.398942,0.559701,-0.286531,0.431892,-0.518969,0.187864
0.82,0.398942,0.56661,-0.279658,0.453703,-0.512775,0.178959
0.83,0.398942,0.57352,-0.272525,0.475781,-0.505788,0.169946
0.84,0.398942,0.58043,-0.265109,0.498127,-0.497954,0.160823
0.85,0.398942,0.58734,-0.257387,0.520741,-0.489205,0.151591
0.86,0.398942,0.59425,-0.249331,0.543623,-0.479468,0.14225
0.87,0.398942,0.60116,-0.240906,0.566772,-0.468654,0.132799
0.88,0.398942,0.60807,-0.232073,0.590188,-0.45666,0.123239
0.89,0.398942,0.61498,-0.222783,0.613873,-0.443361,0.11357
0.9,0.398942,0.621889,-0.212977,0.637824,-0.428608,0.103792
0.91,0.398942,0.628799,-0.202579,0.662044,-0.412211,0.0939045
0.92,0.398942,0.635709,-0.191492,0.686531,-0.393935,0.0839077
0.93,0.398942,0.642619,-0.179591,0.711286,-0.373466,0.0738016
0.94,0.398942,0.649529,-0.166699,0.736308,-0.350385,0.0635863
0.95,0.398942,0.656439,-0.152566,0.761598,-0.324091,0.0532617
0.96,0.398942,0.663349,-0.136809,0.787156,-0.293677,0.0428279
0.97,0.398942,0.670259,-0.118782,0.812981,-0.257636,0.0322848
0.98,0.398942,0.677169,-0.0972307,0.839074,-0.213066,0.0216325
0.99,0.398942,0.684078,-0.0689259,0.865434,-0.152582,0.0108709
code/python/examples.py
deleted
100644 → 0
View file @
796bfdd0
from
mpl_toolkits
import
mplot3d
import
numpy
as
np
import
matplotlib.pyplot
as
plt
#fig = plt.figure(figsize=plt.figaspect(1.))
#ax = fig.add_subplot(111, projection='3d')
fig
=
plt
.
figure
()
ax
=
plt
.
axes
(
projection
=
'3d'
)
# Data for a three-dimensional line
zline
=
np
.
linspace
(
0
,
15
,
1000
)
xline
=
np
.
sin
(
zline
)
yline
=
np
.
cos
(
zline
)
ax
.
plot3D
(
xline
,
yline
,
zline
,
'gray'
)
# Data for three-dimensional scattered points
zdata
=
15
*
np
.
random
.
random
(
100
)
xdata
=
np
.
sin
(
zdata
)
+
0.1
*
np
.
random
.
randn
(
100
)
ydata
=
np
.
cos
(
zdata
)
+
0.1
*
np
.
random
.
randn
(
100
)
ax
.
scatter3D
(
xdata
,
ydata
,
zdata
,
c
=
zdata
,
cmap
=
'Greens'
);
#plt.show()
def
f
(
x
,
y
):
return
np
.
sin
(
np
.
sqrt
(
x
**
2
+
y
**
2
))
x
=
np
.
linspace
(
-
6
,
6
,
30
)
y
=
np
.
linspace
(
-
6
,
6
,
30
)
X
,
Y
=
np
.
meshgrid
(
x
,
y
)
Z
=
f
(
X
,
Y
)
fig
=
plt
.
figure
()
ax
=
plt
.
axes
(
projection
=
'3d'
)
ax
.
plot_wireframe
(
X
,
Y
,
Z
,
color
=
'black'
)
ax
.
set_title
(
'wireframe'
);
plt
.
show
()
x
=
[
1
,
2
,
3
]
y
=
[
4
,
5
,
6
]
x1
=
np
.
linspace
(
0
,
10
,
1000
)
figure
,
axes
=
plt
.
subplots
(
nrows
=
2
,
ncols
=
2
)
axes
[
0
,
0
].
plot
(
x
,
y
)
#create specific subplots
axes
[
0
,
1
].
plot
(
x1
,
np
.
sin
(
x1
))
axes
[
1
,
0
].
plot
(
x1
,
np
.
cos
(
x1
))
axes
[
1
,
1
].
plot
(
range
(
10
))
figure
.
tight_layout
()
plt
.
show
()
code/python/harmonicTest.csv
deleted
100644 → 0
View file @
796bfdd0
This source diff could not be displayed because it is too large. You can
view the blob
instead.
code/python/plotAssLegendre.py
deleted
100644 → 0
View file @
796bfdd0
# importing the required module
import
matplotlib.pyplot
as
plt
import
csv
import
numpy
as
np
'''
# x axis values
x = [1, 2, 3]
# corresponding y axis values
y = [2, 4, 1]
# plotting the points
plt.plot(x, y)
# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')
# giving a title to my graph
plt.title('My first graph!')
# function to show the plot
plt.show()
'''
# Read csv data
my
=
[]
moments
=
list
(
list
())
with
open
(
'assLegendre.csv'
)
as
csv_file
:
csv_reader
=
csv
.
reader
(
csv_file
,
delimiter
=
','
)
line_count
=
0
for
row
in
csv_reader
:
my
.
append
(
row
[
0
])
moments
.
append
(
row
[
1
:])
#transform to array
momentsArr
=
np
.
array
(
moments
)
myArr
=
np
.
array
(
my
)
# plot stuff
print
(
len
(
momentsArr
[
0
,:]))
#for idx in range (0, len(momentsArr[0,:])):
# print(idx)
# print("\n")
print
(
momentsArr
[:,
2
])
print
(
myArr
)
plt
.
plot
(
myArr
,
momentsArr
[:,
2
],
label
=
1
)
print
(
"------------------
\n
"
)
axes
=
plt
.
gca
()
#axes.set_xlim([-1, 1])
#axes.set_ylim([-2, 2])
#plt.legend()
plt
.
show
()
code/python/plotBasis.py
deleted
100644 → 0
View file @
796bfdd0
import
matplotlib.pyplot
as
plt
from
matplotlib
import
cm
,
colors
from
mpl_toolkits.mplot3d
import
Axes3D
import
numpy
as
np
from
scipy.special
import
sph_harm
# This import registers the 3D projection, but is otherwise unused.
from
mpl_toolkits.mplot3d
import
Axes3D
# noqa: F401 unused import
#--------------------------#
# Own Values #
#--------------------------#
# read in own coordinates
import
csv
ndimGrid
=
51
X
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Y
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Z
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
X0
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Y0
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Z0
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
X1
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Y1
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Z1
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
X2
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Y2
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Z2
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm0
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm1
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm2
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm3
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm4
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm5
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm6
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm7
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
Harm8
=
np
.
zeros
((
ndimGrid
,
ndimGrid
))
idx_row
=
0
idx_col
=
0
#fill grid_data with values
with
open
(
'harmonicTest.csv'
)
as
csv_file
:
csv_reader
=
csv
.
reader
(
csv_file
,
delimiter
=
','
)
line_count
=
0
for
row
in
csv_reader
:
if
line_count
==
0
:
print
(
f
'Column names are
{
", "
.
join
(
row
)
}
'
)
line_count
+=
1
else
:
#fill grid data: row[0]
idx_col
=
(
line_count
-
1
)
%
ndimGrid
idx_row
=
(
line_count
-
1
)
//
ndimGrid
print
(
str
(
line_count
)
+
' '
+
str
(
idx_row
)
+
' '
+
str
(
idx_col
)
)
my
=
float
(
row
[
0
])
phi
=
float
(
row
[
1
])
X
[
idx_row
,
idx_col
]
=
np
.
sqrt
(
1
-
my
*
my
)
*
np
.
cos
(
phi
)
Y
[
idx_row
,
idx_col
]
=
np
.
sqrt
(
1
-
my
*
my
)
*
np
.
sin
(
phi
)
Z
[
idx_row
,
idx_col
]
=
my
Harm0
[
idx_row
,
idx_col
]
=
row
[
2
]
Harm1
[
idx_row
,
idx_col
]
=
row
[
3
]
Harm2
[
idx_row
,
idx_col
]
=
row
[
4
]
Harm3
[
idx_row
,
idx_col
]
=
row
[
5
]
Harm4
[
idx_row
,
idx_col
]
=
row
[
6
]
Harm5
[
idx_row
,
idx_col
]
=
row
[
7
]
Harm6
[
idx_row
,
idx_col
]
=
row
[
8
]
Harm7
[
idx_row
,
idx_col
]
=
row
[
9
]
Harm8
[
idx_row
,
idx_col
]
=
row
[
10
]
line_count
+=
1
# radius version
X0
[
idx_row
,
idx_col
]
=
X
[
idx_row
,
idx_col
]
*
Harm0
[
idx_row
,
idx_col
]
Y0
[
idx_row
,
idx_col
]
=
Y
[
idx_row
,
idx_col
]
*
Harm0
[
idx_row
,
idx_col
]
Z0
[
idx_row
,
idx_col
]
=
Z
[
idx_row
,
idx_col
]
*
Harm0
[
idx_row
,
idx_col
]
X1
[
idx_row
,
idx_col
]
=
X
[
idx_row
,
idx_col
]
*
Harm1
[
idx_row
,
idx_col
]
Y1
[
idx_row
,
idx_col
]
=
Y
[
idx_row
,
idx_col
]
*
Harm1
[
idx_row
,
idx_col
]
Z1
[
idx_row
,
idx_col
]
=
Z
[
idx_row
,
idx_col
]
*
Harm1
[
idx_row
,
idx_col
]
X2
[
idx_row
,
idx_col
]
=
X
[
idx_row
,
idx_col
]
*
Harm2
[
idx_row
,
idx_col
]
Y2
[
idx_row
,
idx_col
]
=
Y
[
idx_row
,
idx_col
]
*
Harm2
[
idx_row
,
idx_col
]
Z2
[
idx_row
,
idx_col
]
=
Z
[
idx_row
,
idx_col
]
*
Harm2
[
idx_row
,
idx_col
]
print
(
f
'Processed
{
line_count
}
lines.'
)
# setup colors
fmax
,
fmin
=
Harm0
.
max
(),
Harm0
.
min
()
fcolors0
=
(
Harm0
)
# constan function - fmin)/(fmax - fmin)
fmax
,
fmin
=
Harm1
.
max
(),
Harm1
.
min
()
fcolors1
=
(
Harm1
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm2
.
max
(),
Harm2
.
min
()
fcolors2
=
(
Harm2
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm3
.
max
(),
Harm3
.
min
()
fcolors3
=
(
Harm3
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm4
.
max
(),
Harm4
.
min
()
fcolors4
=
(
Harm4
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm5
.
max
(),
Harm5
.
min
()
fcolors5
=
(
Harm5
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm6
.
max
(),
Harm6
.
min
()
fcolors6
=
(
Harm6
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm7
.
max
(),
Harm7
.
min
()
fcolors7
=
(
Harm7
-
fmin
)
/
(
fmax
-
fmin
)
fmax
,
fmin
=
Harm8
.
max
(),
Harm8
.
min
()
fcolors8
=
(
Harm8
-
fmin
)
/
(
fmax
-
fmin
)
# set up a figure twice as wide as it is tall
fig
=
plt
.
figure
(
figsize
=
plt
.
figaspect
(
1
))
# first plot
ax
=
fig
.
add_subplot
(
3
,
3
,
1
,
projection
=
'3d'
)
surf
=
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors0
))
ax
.
set_axis_off
()
#second plot
ax
=
fig
.
add_subplot
(
3
,
3
,
2
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors1
))
ax
.
set_axis_off
()
#third plot
ax
=
fig
.
add_subplot
(
3
,
3
,
3
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors2
))
ax
.
set_axis_off
()
#fourth plot
ax
=
fig
.
add_subplot
(
3
,
3
,
4
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors3
))
ax
.
set_axis_off
()
ax
=
fig
.
add_subplot
(
3
,
3
,
5
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors4
))
ax
.
set_axis_off
()
ax
=
fig
.
add_subplot
(
3
,
3
,
6
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors5
))
ax
.
set_axis_off
()
ax
=
fig
.
add_subplot
(
3
,
3
,
7
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors6
))
ax
.
set_axis_off
()
ax
=
fig
.
add_subplot
(
3
,
3
,
8
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors7
))
ax
.
set_axis_off
()
ax
=
fig
.
add_subplot
(
3
,
3
,
9
,
projection
=
'3d'
)
ax
.
plot_surface
(
X
,
Y
,
Z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors8
))
ax
.
set_axis_off
()
plt
.
show
()
#--------------------------#
# Reference Values #
#--------------------------#
phi
=
np
.
linspace
(
0
,
np
.
pi
,
100
)
theta
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
100
)
phi
,
theta
=
np
.
meshgrid
(
phi
,
theta
)
# The Cartesian coordinates of the unit sphere
x
=
np
.
sin
(
phi
)
*
np
.
cos
(
theta
)
y
=
np
.
sin
(
phi
)
*
np
.
sin
(
theta
)
z
=
np
.
cos
(
phi
)
m
,
l
=
0
,
1
# Calculate the spherical harmonic Y(l,m) and normalize to [0,1]
fcolors
=
sph_harm
(
m
,
l
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors
.
max
(),
fcolors
.
min
()
fcolors
=
(
fcolors
-
fmin
)
/
(
fmax
-
fmin
)
# Set the aspect ratio to 1 so our sphere looks spherical
fig
=
plt
.
figure
(
figsize
=
plt
.
figaspect
(
1.
))
ax
=
fig
.
add_subplot
(
111
,
projection
=
'3d'
)
ax
.
plot_surface
(
x
,
y
,
z
,
rstride
=
1
,
cstride
=
1
,
facecolors
=
cm
.
seismic
(
fcolors
))
# Turn off the axis planes
ax
.
set_axis_off
()
plt
.
show
()
# setup colors
fcolors00
=
sph_harm
(
0
,
0
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors00
.
max
(),
fcolors00
.
min
()
#fcolors00 = (fcolors00 - fmin)/(fmax - fmin)
fcolors01
=
sph_harm
(
-
1
,
1
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors01
.
max
(),
fcolors01
.
min
()
fcolors01
=
(
fcolors01
-
fmin
)
/
(
fmax
-
fmin
)
fcolors02
=
sph_harm
(
0
,
1
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors02
.
max
(),
fcolors02
.
min
()
fcolors02
=
(
fcolors02
-
fmin
)
/
(
fmax
-
fmin
)
fcolors03
=
sph_harm
(
1
,
1
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors03
.
max
(),
fcolors03
.
min
()
fcolors03
=
(
fcolors03
-
fmin
)
/
(
fmax
-
fmin
)
fcolors04
=
sph_harm
(
-
2
,
2
,
theta
,
phi
).
real
fmax
,
fmin
=
fcolors04
.
max
(),
fcolors04
.
min
()
fcolors04
=
(
fcolors04
-
fmin
)
/
(
fmax
-
fmin
)