Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
teqp_fork_old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Sven Michael Pohl
teqp_fork_old
Commits
75b74acc
Commit
75b74acc
authored
3 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Add simple euler to odeint test
parent
29927c31
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test_boost_odeint.cpp
+21
-1
21 additions, 1 deletion
src/test_boost_odeint.cpp
with
21 additions
and
1 deletion
src/test_boost_odeint.cpp
+
21
−
1
View file @
75b74acc
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
<boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
#include
<boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
#include
<boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp>
#include
<boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp>
#include
<boost/numeric/odeint/stepper/euler.hpp>
/* The type of container used to hold the state vector */
/* The type of container used to hold the state vector */
typedef
std
::
vector
<
double
>
state_type
;
typedef
std
::
vector
<
double
>
state_type
;
...
@@ -29,7 +30,7 @@ int main(int /* argc */ , char** /* argv */ )
...
@@ -29,7 +30,7 @@ int main(int /* argc */ , char** /* argv */ )
state_type
x0
=
{
1.0
,
0.0
};
// Starting point
state_type
x0
=
{
1.0
,
0.0
};
// Starting point
// First integrate, adaptively, until you get as close to the end as you can
// First integrate, adaptively, until you get as close to the end as you can
double
t
=
0
,
dt
=
0.001
,
tmax
=
10
0
.0
;
double
t
=
0
,
dt
=
0.001
,
tmax
=
10.0
;
auto
write
=
[
&
]()
{
std
::
cout
<<
t
<<
" "
<<
x0
[
0
]
<<
","
<<
x0
[
1
]
<<
std
::
endl
;
};
auto
write
=
[
&
]()
{
std
::
cout
<<
t
<<
" "
<<
x0
[
0
]
<<
","
<<
x0
[
1
]
<<
std
::
endl
;
};
for
(
auto
i
=
0
;
t
<
tmax
;
++
i
){
for
(
auto
i
=
0
;
t
<
tmax
;
++
i
){
if
(
t
+
dt
>
tmax
)
{
break
;
}
if
(
t
+
dt
>
tmax
)
{
break
;
}
...
@@ -41,4 +42,23 @@ int main(int /* argc */ , char** /* argv */ )
...
@@ -41,4 +42,23 @@ int main(int /* argc */ , char** /* argv */ )
double
dtfinal
=
tmax
-
t
;
double
dtfinal
=
tmax
-
t
;
auto
status
=
controlled_stepper
.
try_step
(
xprime
,
x0
,
t
,
dtfinal
);
auto
status
=
controlled_stepper
.
try_step
(
xprime
,
x0
,
t
,
dtfinal
);
write
();
write
();
{
state_type
x0
=
{
1.0
,
0.0
};
// Starting point
euler
<
state_type
>
eul
;
double
t
=
0
,
dt
=
0.01
,
tmax
=
10.0
;
auto
write
=
[
&
]()
{
std
::
cout
<<
t
<<
" "
<<
x0
[
0
]
<<
","
<<
x0
[
1
]
<<
std
::
endl
;
};
for
(
auto
i
=
0
;
t
<
tmax
;
++
i
)
{
if
(
t
+
dt
>
tmax
)
{
break
;
}
write
();
eul
.
do_step
(
xprime
,
x0
,
t
,
dt
);
t
+=
dt
;
}
write
();
double
dtfinal
=
tmax
-
t
;
eul
.
do_step
(
xprime
,
x0
,
t
,
dt
);
write
();
}
}
}
\ No newline at end of file
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