Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slab
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
polarization
slab
Commits
7907ceea
Commit
7907ceea
authored
2 months ago
by
Ruben Farinelli
Browse files
Options
Downloads
Patches
Plain Diff
Added exponential distribution of seed photons for the ODE method
parent
ec06623c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
compute_stokes.c
+7
-7
7 additions, 7 deletions
compute_stokes.c
main_program.c
+2
-1
2 additions, 1 deletion
main_program.c
mc_slab.c
+3
-3
3 additions, 3 deletions
mc_slab.c
plot_data.py
+53
-0
53 additions, 0 deletions
plot_data.py
solve_rte.c
+48
-0
48 additions, 0 deletions
solve_rte.c
with
113 additions
and
11 deletions
compute_stokes.c
+
7
−
7
View file @
7907ceea
...
@@ -55,9 +55,9 @@ void compute_stokes(double ene, double* k_lab, double* polvect_cart, stokes_para
...
@@ -55,9 +55,9 @@ void compute_stokes(double ene, double* k_lab, double* polvect_cart, stokes_para
exit
(
1
);
exit
(
1
);
}
}
ptr_stokes
[
ii
].
array_I
s
[
jj
]
=
ptr_stokes
[
ii
].
array_I
s
[
jj
]
+
1
;
ptr_stokes
[
ii
].
array_I
[
jj
]
=
ptr_stokes
[
ii
].
array_I
[
jj
]
+
1
;
ptr_stokes
[
ii
].
array_Q
s
[
jj
]
=
ptr_stokes
[
ii
].
array_Q
s
[
jj
]
+
Qs
;
ptr_stokes
[
ii
].
array_Q
[
jj
]
=
ptr_stokes
[
ii
].
array_Q
[
jj
]
+
Qs
;
ptr_stokes
[
ii
].
array_U
s
[
jj
]
=
ptr_stokes
[
ii
].
array_U
s
[
jj
]
+
Us
;
ptr_stokes
[
ii
].
array_U
[
jj
]
=
ptr_stokes
[
ii
].
array_U
[
jj
]
+
Us
;
ptr_stokes
[
ii
].
counter
[
jj
]
++
;
ptr_stokes
[
ii
].
counter
[
jj
]
++
;
FlagFound
=
TRUE
;
FlagFound
=
TRUE
;
...
@@ -103,11 +103,11 @@ void compute_stokes(double ene, double* k_lab, double* polvect_cart, stokes_para
...
@@ -103,11 +103,11 @@ void compute_stokes(double ene, double* k_lab, double* polvect_cart, stokes_para
for
(
ii
=
0
;
ii
<
POLAR_NBOUNDS
-
1
;
ii
++
)
for
(
ii
=
0
;
ii
<
POLAR_NBOUNDS
-
1
;
ii
++
)
{
{
Itot_allbands
=
Itot_allbands
+
ptr_stokes
[
ii
].
array_I
s
[
jj
];
Itot_allbands
=
Itot_allbands
+
ptr_stokes
[
ii
].
array_I
[
jj
];
Qtot
=
Qtot
+
ptr_stokes
[
ii
].
array_Q
s
[
jj
];
Qtot
=
Qtot
+
ptr_stokes
[
ii
].
array_Q
[
jj
];
Utot
=
Utot
+
ptr_stokes
[
ii
].
array_U
s
[
jj
];
Utot
=
Utot
+
ptr_stokes
[
ii
].
array_U
[
jj
];
Itot
=
Itot
+
ptr_stokes
[
ii
].
array_I
s
[
jj
];
Itot
=
Itot
+
ptr_stokes
[
ii
].
array_I
[
jj
];
if
(
isnan
(
Qtot
))
if
(
isnan
(
Qtot
))
{
{
...
...
This diff is collapsed.
Click to expand it.
main_program.c
+
2
−
1
View file @
7907ceea
...
@@ -58,7 +58,8 @@ int main(int argc, char* argv[])
...
@@ -58,7 +58,8 @@ int main(int argc, char* argv[])
printf
(
"
\n
Seed photons distributions: three options are possible with parameter seed=N
\n
"
);
printf
(
"
\n
Seed photons distributions: three options are possible with parameter seed=N
\n
"
);
printf
(
"1: photons at the center of the slab
\n
"
);
printf
(
"1: photons at the center of the slab
\n
"
);
printf
(
"2: photons uniform distribution
\n
"
);
printf
(
"2: photons uniform distribution
\n
"
);
printf
(
"3: photons at the base (valid only for ode and mc methods)
\n\n
"
);
printf
(
"3: photons at the base (valid only for ode and mc methods)
\n
"
);
printf
(
"4: photons with exponential distribution (valid only for ode and mc methods)
\n\n
"
);
printf
(
"Parameters for iteration algorithms
\n
"
);
printf
(
"Parameters for iteration algorithms
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
mc_slab.c
+
3
−
3
View file @
7907ceea
...
@@ -341,13 +341,13 @@ int slab_mc(int nphot, int seed)
...
@@ -341,13 +341,13 @@ int slab_mc(int nphot, int seed)
for
(
ii
=
0
;
ii
<
POLAR_NBOUNDS
-
1
;
ii
++
)
for
(
ii
=
0
;
ii
<
POLAR_NBOUNDS
-
1
;
ii
++
)
{
{
MPI_Reduce
(
struct_stokes
[
ii
].
array_I
s
,
struct_stokes_average
[
ii
].
array_I
s
,
nstepangles
,
MPI_Reduce
(
struct_stokes
[
ii
].
array_I
,
struct_stokes_average
[
ii
].
array_I
,
nstepangles
,
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
struct_stokes
[
ii
].
array_Q
s
,
struct_stokes_average
[
ii
].
array_Q
s
,
nstepangles
,
MPI_Reduce
(
struct_stokes
[
ii
].
array_Q
,
struct_stokes_average
[
ii
].
array_Q
,
nstepangles
,
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
struct_stokes
[
ii
].
array_U
s
,
struct_stokes_average
[
ii
].
array_U
s
,
nstepangles
,
MPI_Reduce
(
struct_stokes
[
ii
].
array_U
,
struct_stokes_average
[
ii
].
array_U
,
nstepangles
,
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_DOUBLE
,
MPI_SUM
,
0
,
MPI_COMM_WORLD
);
MPI_Reduce
(
struct_stokes
[
ii
].
counter
,
struct_stokes_average
[
ii
].
counter
,
nstepangles
,
MPI_INT
,
MPI_Reduce
(
struct_stokes
[
ii
].
counter
,
struct_stokes_average
[
ii
].
counter
,
nstepangles
,
MPI_INT
,
...
...
This diff is collapsed.
Click to expand it.
plot_data.py
0 → 100755
+
53
−
0
View file @
7907ceea
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
mpl_toolkits.mplot3d
import
Axes3D
def
read_data
(
file_path
):
"""
Read the data from the input file and extract X, Y, and Z values.
Assumes the data format is X Y Z in each line.
"""
X
,
Y
,
Z
=
np
.
loadtxt
(
file_path
,
unpack
=
True
)
return
X
,
Y
,
Z
def
plot_3d_histogram
(
X
,
Y
,
Z
,
bins_x
,
bins_y
):
"""
Plot a 3D histogram using bar3d with square bins.
"""
H
,
xedges
,
yedges
=
np
.
histogram2d
(
X
,
Y
,
bins
=
[
bins_x
,
bins_y
])
X
,
Y
=
np
.
meshgrid
(
xedges
[:
-
1
],
yedges
[:
-
1
])
# Set the widths and depths of the bars to make them square
dx
=
(
xedges
[
1
]
-
xedges
[
0
])
dy
=
(
yedges
[
1
]
-
yedges
[
0
])
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
,
projection
=
'
3d
'
)
# Flatten the arrays
X
=
X
.
ravel
()
Y
=
Y
.
ravel
()
Z
=
np
.
zeros_like
(
X
)
dx
=
np
.
full_like
(
X
,
dx
)
dy
=
np
.
full_like
(
X
,
dy
)
ax
.
bar3d
(
X
,
Y
,
Z
,
dx
,
dy
,
H
.
ravel
(),
shade
=
True
)
ax
.
set_xlabel
(
'
X
'
)
ax
.
set_ylabel
(
'
Y
'
)
ax
.
set_zlabel
(
'
Frequency
'
)
ax
.
set_title
(
'
3D Histogram of Z(x, y)
'
)
plt
.
show
()
if
__name__
==
"
__main__
"
:
# Path to the input file (replace with your file path)
file_path
=
'
data.txt
'
# Read data from the input file
X
,
Y
,
Z
=
read_data
(
file_path
)
# Number of bins for X and Y axes
bins_x
=
40
# Adjust as needed
bins_y
=
40
# Adjust as needed
# Plot the 3D histogram
plot_3d_histogram
(
X
,
Y
,
Z
,
bins_x
,
bins_y
)
This diff is collapsed.
Click to expand it.
solve_rte.c
+
48
−
0
View file @
7907ceea
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
double
I0_center_updown
(
double
tau
,
double
u
);
double
I0_center_updown
(
double
tau
,
double
u
);
double
I0_upward
(
double
tau
,
double
u
);
double
I0_upward
(
double
tau
,
double
u
);
double
I0_uniform_updown
(
double
tau
,
double
u
);
double
I0_uniform_updown
(
double
tau
,
double
u
);
double
I0_exp_upward
(
double
tau
,
double
u
);
double
I0_exp_downward
(
double
tau
,
double
u
);
void
set_spline2d_obj
(
gsl_spline2d
*
Spline_I2d
,
double
*
za
,
double
**
I_funct
);
void
set_spline2d_obj
(
gsl_spline2d
*
Spline_I2d
,
double
*
za
,
double
**
I_funct
);
int
set_array_idx
(
double
tau_prev
,
double
tau
,
double
*
array
,
int
nstep
);
int
set_array_idx
(
double
tau_prev
,
double
tau
,
double
*
array
,
int
nstep
);
...
@@ -117,6 +120,19 @@ int solve_rte(int k_iter, int seed_distribution, int Nstep_tau)
...
@@ -117,6 +120,19 @@ int solve_rte(int k_iter, int seed_distribution, int Nstep_tau)
ptr_Iklr
[
0
].
Il_matrix_downstream
[
ii
][
jj
]
=
0
;
ptr_Iklr
[
0
].
Il_matrix_downstream
[
ii
][
jj
]
=
0
;
ptr_Iklr
[
0
].
Ir_matrix_downstream
[
ii
][
jj
]
=
0
;
ptr_Iklr
[
0
].
Ir_matrix_downstream
[
ii
][
jj
]
=
0
;
}
}
else
if
(
seed_distribution
==
SEED_EXP
)
{
ptr_Iklr
[
0
].
Il_matrix_upstream
[
ii
][
jj
]
=
I0_exp_upward
(
array_tau
[
ii
],
array_mu
[
jj
]);
ptr_Iklr
[
0
].
Ir_matrix_upstream
[
ii
][
jj
]
=
I0_exp_upward
(
array_tau
[
ii
],
array_mu
[
jj
]);
ptr_Iklr
[
0
].
Il_matrix_downstream
[
ii
][
jj
]
=
I0_exp_downward
(
array_tau
[
ii
],
array_mu
[
jj
]);
ptr_Iklr
[
0
].
Ir_matrix_downstream
[
ii
][
jj
]
=
I0_exp_downward
(
array_tau
[
ii
],
array_mu
[
jj
]);
}
else
else
{
{
printf
(
printf
(
...
@@ -361,6 +377,38 @@ int RTE_Equations(double s, const double y[], double f[], void* params)
...
@@ -361,6 +377,38 @@ int RTE_Equations(double s, const double y[], double f[], void* params)
return
GSL_SUCCESS
;
return
GSL_SUCCESS
;
}
}
/*====================================================================*/
/*Value of the I^k(tau,u) function for k=0 and seed photons*/
/*with exponential distribution for u > 0 and u < 0*/
/*====================================================================*/
double
I0_exp_upward
(
double
tau
,
double
u
)
{
double
value
;
value
=
((
-
1
+
exp
(((
-
1
+
u
)
*
tau
)
/
u
)))
/
(
2
.
0
*
exp
(
tau
)
*
(
-
1
+
u
));
return
value
;
}
double
I0_exp_downward
(
double
tau
,
double
u
)
{
double
value
;
value
=
(
exp
(
-
2
*
tau0
)
*
(
exp
(
tau
)
-
exp
(
-
tau
/
u
)))
/
(
2
.
0
*
(
1
+
u
));
return
value
;
}
/*====================================================================*/
/*====================================================================*/
/*Value of the I^k(tau,u) function for k=0 and seed photons*/
/*Value of the I^k(tau,u) function for k=0 and seed photons*/
/*at the base of the slab (tau=0)*/
/*at the base of the slab (tau=0)*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment