Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nptool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
np
nptool
Commits
143117c1
Commit
143117c1
authored
3 days ago
by
Theodore Efremov
Browse files
Options
Downloads
Patches
Plain Diff
[Exogam] Added sanity check for failed NR convergence and fixed returned var in this case
parent
2556a9d5
No related branches found
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
NPLib/Detectors/Exogam/TExogamGeo.cxx
+8
-3
8 additions, 3 deletions
NPLib/Detectors/Exogam/TExogamGeo.cxx
NPLib/Detectors/Exogam/TExogamGeo.h
+1
-1
1 addition, 1 deletion
NPLib/Detectors/Exogam/TExogamGeo.h
with
9 additions
and
4 deletions
NPLib/Detectors/Exogam/TExogamGeo.cxx
+
8
−
3
View file @
143117c1
...
...
@@ -186,6 +186,7 @@ Vector3D TExogamGeo::newton_raphson(double initial_guess,
Vector3D
&
TargetPos
,
double
tolerance
=
1e-6
,
int
max_iterations
=
100
)
{
double
alpha
=
initial_guess
;
Vector3D
unit
(
0.
,
1.
,
0.
);
Vector3D
fail
;
setclover
(
&
unit
);
// std::cout << "new NewtonRaphson" << std::endl;
for
(
int
i
=
0
;
i
<
max_iterations
;
++
i
)
{
...
...
@@ -204,15 +205,19 @@ Vector3D TExogamGeo::newton_raphson(double initial_guess,
// Si la différence est inférieure à la tolérance, on considère la solution trouvée
if
(
std
::
fabs
(
alpha_new
-
alpha
)
<
tolerance
)
{
return
SegmentPos
-
TargetPos
;
}
// std::cout << alpha << " " << alpha_new << std::endl;
alpha
=
alpha_new
;
fail
=
SegmentPos
-
TargetPos
;
}
std
::
cerr
<<
"Newton-Raphson n'a pas convergé après "
<<
max_iterations
<<
" itérations.
\n
"
;
Vector3D
fail
;
// If failed convergence is wrong by more than 100% of initial guess just return initial guess
if
((
std
::
fabs
(
alpha
-
initial_guess
)
>
(
initial_guess
*
2
))
){
Vector3D
outerpos
=
getouterpos
(
initial_guess
,
InteractionDepth
);
Vector3D
SegmentPos
(
outerpos
.
X
(),
getdistance
()
+
std
::
cos
(
initial_guess
)
*
InteractionDepth
,
outerpos
.
Z
());
fail
=
SegmentPos
-
TargetPos
;
}
return
fail
;
// Retourne la dernière valeur trouvée si la convergence n'est pas atteinte
}
...
...
This diff is collapsed.
Click to expand it.
NPLib/Detectors/Exogam/TExogamGeo.h
+
1
−
1
View file @
143117c1
...
...
@@ -212,4 +212,4 @@ class TExogamCartesian: public TExogamGeo{
double
getdistance
()
override
;
double
tolerance
=
1
;
// tolerance is in mm
};
#endif
\ No newline at end of file
#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