Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
SWIFT
QuickSched
Commits
bd32afdd
Commit
bd32afdd
authored
10 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Apply simple cubic bias correction in the side case
parent
29f893de
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/plot_sorted.py
+13
-13
13 additions, 13 deletions
examples/plot_sorted.py
examples/test_bh_sorted.c
+23
-7
23 additions, 7 deletions
examples/test_bh_sorted.c
with
36 additions
and
20 deletions
examples/plot_sorted.py
+
13
−
13
View file @
bd32afdd
...
@@ -36,7 +36,7 @@ import os
...
@@ -36,7 +36,7 @@ import os
from
scipy
import
stats
from
scipy
import
stats
from
scipy
import
optimize
from
scipy
import
optimize
dist_cutoff_ratio
=
1.
5
dist_cutoff_ratio
=
1.
2
ortho_max_fit
=
0.2
ortho_max_fit
=
0.2
ortho_min_fit
=
0.
ortho_min_fit
=
0.
ortho_max
=
2.5
ortho_max
=
2.5
...
@@ -79,14 +79,14 @@ limit_exact = ( dist_cutoff_ratio - 1. )
...
@@ -79,14 +79,14 @@ limit_exact = ( dist_cutoff_ratio - 1. )
print
limit_exact
print
limit_exact
#names = ["side", "edge", "corner"]
#names = ["side", "edge", "corner"]
for
orientation
in
range
(
26
):
#
for orientation in range( 26 ):
#
for jjj in range(0,3):
for
jjj
in
range
(
0
,
3
):
#
if jjj == 0:
if
jjj
==
0
:
#
orientation = 0
orientation
=
0
#
if jjj == 1:
if
jjj
==
1
:
#
orientation = 1
orientation
=
1
#
if jjj == 2:
if
jjj
==
2
:
#
orientation = 4
orientation
=
4
# Read Quickshed accelerations
# Read Quickshed accelerations
data
=
loadtxt
(
"
interaction_dump_%d.dat
"
%
orientation
)
data
=
loadtxt
(
"
interaction_dump_%d.dat
"
%
orientation
)
...
@@ -168,8 +168,8 @@ for orientation in range( 26 ):
...
@@ -168,8 +168,8 @@ for orientation in range( 26 ):
delta
=
sim
/
exact
delta
=
sim
/
exact
# parabola_param1,pcov = optimize.curve_fit(parabola, xx, delta, p0=[1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# parabola_param1,pcov = optimize.curve_fit(parabola, xx, delta, p0=[1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# #print parabola_param1
# #print parabola_param1
#
cubic_param1,pcov = optimize.curve_fit(cubic, xx, delta, p0=[1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
cubic_param1
,
pcov
=
optimize
.
curve_fit
(
cubic
,
xx
,
delta
,
p0
=
[
1
,
1
,
1
,
1
],
sigma
=
None
,
maxfev
=
100000
,
xtol
=
1e-13
,
ftol
=
1e-13
)
#
print cubic_param1
print
cubic_param1
# quartic_param1,pcov = optimize.curve_fit(quartic, xx, delta, p0=[1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# quartic_param1,pcov = optimize.curve_fit(quartic, xx, delta, p0=[1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# #print quartic_param1
# #print quartic_param1
# quintic_param1,pcov = optimize.curve_fit(quintic, xx, delta, p0=[1,1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# quintic_param1,pcov = optimize.curve_fit(quintic, xx, delta, p0=[1,1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
...
@@ -200,8 +200,8 @@ for orientation in range( 26 ):
...
@@ -200,8 +200,8 @@ for orientation in range( 26 ):
delta
=
sim
/
exact
delta
=
sim
/
exact
# parabola_param2,pcov = optimize.curve_fit(parabola, xx, delta, p0=[1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# parabola_param2,pcov = optimize.curve_fit(parabola, xx, delta, p0=[1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# #print parabola_param2
# #print parabola_param2
#
cubic_param2,pcov = optimize.curve_fit(cubic, xx, delta, p0=[1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
cubic_param2
,
pcov
=
optimize
.
curve_fit
(
cubic
,
xx
,
delta
,
p0
=
[
1
,
1
,
1
,
1
],
sigma
=
None
,
maxfev
=
100000
,
xtol
=
1e-13
,
ftol
=
1e-13
)
#
print cubic_param2
print
cubic_param2
# quartic_param2,pcov = optimize.curve_fit(quartic, xx, delta, p0=[1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# quartic_param2,pcov = optimize.curve_fit(quartic, xx, delta, p0=[1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# #print quartic_param2
# #print quartic_param2
# quintic_param2,pcov = optimize.curve_fit(quintic, xx, delta, p0=[1,1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
# quintic_param2,pcov = optimize.curve_fit(quintic, xx, delta, p0=[1,1,1,1,1,1], sigma=None, maxfev=100000, xtol=1e-13, ftol=1e-13)
...
...
This diff is collapsed.
Click to expand it.
examples/test_bh_sorted.c
+
23
−
7
View file @
bd32afdd
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
#define task_limit 1e8
#define task_limit 1e8
#define const_G 1 // 6.6738e-8
#define const_G 1 // 6.6738e-8
#define dist_min 0.5
/* Used for legacy walk only */
#define dist_min 0.5
/* Used for legacy walk only */
#define dist_cutoff_ratio 1.
5
#define dist_cutoff_ratio 1.
2
#define iact_pair_direct iact_pair_direct_sorted_multipole
#define iact_pair_direct iact_pair_direct_sorted_multipole
#define ICHECK -1
#define ICHECK -1
#define NO_SANITY_CHECKS
#define NO_SANITY_CHECKS
...
@@ -1170,11 +1170,17 @@ float correction_coefs[6*4] =
...
@@ -1170,11 +1170,17 @@ float correction_coefs[6*4] =
-
0
.
043
97042
,
0
.
10367151
,
-
0
.
06130
978
,
1
.
00754152
,
-
0
.
043
97042
,
0
.
10367151
,
-
0
.
06130
978
,
1
.
00754152
,
0
.
00536257
,
-
0
.
06370355
,
0
.
19954405
,
0
.
81828777
,
0
.
00536257
,
-
0
.
06370355
,
0
.
19954405
,
0
.
81828777
,
-
0
.
0067717
9
,
-
0
.
01237365
,
0
.
02703505
,
0
.
99483005
,
-
0
.
0067717
9
,
-
0
.
01237365
,
0
.
02703505
,
0
.
99483005
,
0
.
0
10
82535
,
-
0
.
02625
87
,
0
.
0
03424
99
,
1
.
01511
8
3
,
0
.
0
0701166
,
-
0
.
0113404
,
-
0
.
0
15
9732
,
1
.
02330
93
3
,
-
0
.
00
352327
,
0
.
02770
999
,
-
0
.
02312047
,
1
.
00
2
82468
0
.
00
2
97062
,
0
.
01
928414
,
-
0
.
01
929454
,
1
.
00
1
90972
};
};
static
inline
float
cubic
(
float
x
,
float
a
,
float
b
,
float
c
,
float
d
)
{
return
a
*
x
*
x
*
x
+
b
*
x
*
x
+
c
*
x
+
d
;
}
/**
/**
* @brief Compute the best-fitting bias correction factor for the acceleration of a particle
* @brief Compute the best-fitting bias correction factor for the acceleration of a particle
*
*
...
@@ -1187,7 +1193,6 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
...
@@ -1187,7 +1193,6 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
int
k
,
orientation
;
int
k
,
orientation
;
int
is_zero
[
3
];
int
is_zero
[
3
];
float
limit_exact
=
(
dist_cutoff_ratio
-
1
.
);
/* Start with no applied correction */
/* Start with no applied correction */
corr
[
0
]
=
corr
[
1
]
=
corr
[
2
]
=
1
.
f
;
corr
[
0
]
=
corr
[
1
]
=
corr
[
2
]
=
1
.
f
;
...
@@ -1200,6 +1205,10 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
...
@@ -1200,6 +1205,10 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
}
}
//message("%f %f", d, limit_exact);
//message("%f %f", d, limit_exact);
#if 1
float
limit_exact
=
(
dist_cutoff_ratio
-
1
.
);
/* Apply the correction corresponding to this axis */
/* Apply the correction corresponding to this axis */
switch
(
orientation
)
switch
(
orientation
)
...
@@ -1207,10 +1216,17 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
...
@@ -1207,10 +1216,17 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
case
1
:
/* side */
case
1
:
/* side */
{
{
if
(
d
>
limit_exact
||
d
<
-
limit_exact
)
if
(
d
>
limit_exact
)
for
(
k
=
0
;
k
<
3
;
k
++
)
for
(
k
=
0
;
k
<
3
;
k
++
)
corr
[
k
]
=
0
.;
corr
[
k
]
=
1
.
/
cubic
(
d
,
correction_coefs
[
4
*
4
+
0
],
correction_coefs
[
4
*
4
+
1
],
correction_coefs
[
4
*
4
+
2
],
correction_coefs
[
4
*
4
+
3
]);
else
if
(
d
<
-
limit_exact
)
for
(
k
=
0
;
k
<
3
;
k
++
)
corr
[
k
]
=
1
.
/
cubic
(
d
,
correction_coefs
[
5
*
4
+
0
],
correction_coefs
[
5
*
4
+
1
],
correction_coefs
[
5
*
4
+
2
],
correction_coefs
[
5
*
4
+
3
]);
message
(
"corr= %f %f %f"
,
corr
[
0
],
corr
[
1
],
corr
[
2
]);
}
}
break
;
break
;
...
@@ -1243,7 +1259,7 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
...
@@ -1243,7 +1259,7 @@ static inline void gravity_bias_correction( float d, float axis[3], float corr[3
for
(
k
=
0
;
k
<
3
;
++
k
)
for
(
k
=
0
;
k
<
3
;
++
k
)
corr
[
k
]
=
(
is_zero
[
k
]
?
corr
[
k
]
:
1
);
corr
[
k
]
=
(
is_zero
[
k
]
?
corr
[
k
]
:
1
);
#endif
}
}
...
...
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