Skip to content

Commit 3c90c31

Browse files
Merge pull request #1 from jchristopherson/Development-v1.1.0
Development v1.1.0
2 parents 2ab529c + db4b9d1 commit 3c90c31

File tree

191 files changed

+17830
-3262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+17830
-3262
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ before_install:
99
install:
1010
- sudo apt-get install -qq gfortran-7
1111
- sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-7 90
12+
- sudo apt install git
13+
- sudo apt install cmake
14+
- sudo git clone https://github.com/jchristopherson/ferror.git
15+
- pushd ferror
16+
- sudo mkdir build
17+
- pushd build
18+
- sudo cmake -DCMAKE_INSTALL_LIBDIR=$HOME/.local/ferror ..
19+
- sudo cmake
20+
- sudo make
21+
- sudo make install
22+
- popd
23+
- popd
1224

1325
before_script:
1426
- mkdir build

CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ project(integral C CXX Fortran)
44

55
# Define version information
66
set(INTEGRAL_MAJOR_VERSION 1)
7-
set(INTEGRAL_MINOR_VERSION 0)
7+
set(INTEGRAL_MINOR_VERSION 1)
88
set(INTEGRAL_PATCH_VERSION 0)
99
set(INTEGRAL_VERSION ${INTEGRAL_MAJOR_VERSION}.${INTEGRAL_MINOR_VERSION}.${INTEGRAL_PATCH_VERSION})
1010

@@ -13,11 +13,7 @@ find_package(ferror 1.3.0)
1313

1414
# If FERROR is not installed on the system, build the default implementation
1515
if (NOT ${ferror_FOUND})
16-
message(STATUS "FERROR not found. The default implementation will be used.")
17-
add_subdirectory(src/external/ferror)
18-
include_directories(src/external/ferror/include)
19-
set(FERROR_LIBRARIES ferror)
20-
set(ferror_LibLocation ${ferror_BINARY_DIR})
16+
message(STATUS "FERROR not found.")
2117
else()
2218
message(STATUS "An acceptable version of FERROR (v" ${ferror_VERSION} ") was found, and will be utilized.")
2319
include_directories(${ferror_INCLUDE_DIRS})
@@ -34,8 +30,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
3430
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
3531
endif()
3632

37-
# By default, shared library
38-
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
33+
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
3934

4035
# Export all symbols on Windows when building shared libraries
4136
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

README.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,112 @@ end program
4848
```text
4949
The solution is: 789.97089E-03, the integrator computed: 789.97089E-03.
5050
```
51-
5251
## Example 2
52+
The following example illustrates solution of the Van Der Pol equation comparing two different integrators, an implicit Runge-Kutta integrator (ODE_IRK) and an integrator that automatically switches between an Adams method and a BDF method (ODE_AUTO).
53+
```fortran
54+
program example
55+
use iso_fortran_env
56+
use integral_core
57+
use fplot_core
58+
implicit none
59+
60+
! Local Variables
61+
type(ode_helper) :: fcn
62+
type(ode_irk) :: integrator1
63+
type(ode_auto) :: integrator2
64+
procedure(ode_fcn), pointer :: ptr
65+
real(real64) :: ic(2), t(2)
66+
real(real64), allocatable, dimension(:,:) :: x1, x2
67+
type(plot_2d) :: plt
68+
type(plot_data_2d) :: d1, d2
69+
class(plot_axis), pointer :: xAxis, yAxis
70+
class(legend), pointer :: lgnd
71+
72+
! Set up the integrator
73+
ptr => vdp
74+
call fcn%define_equations(2, ptr)
75+
76+
! Define the initial conditions
77+
t = [0.0d0, 8.0d1]
78+
ic = [2.0d0, 0.0d0]
79+
80+
! Compute the solution
81+
x1 = integrator1%integrate(fcn, t, ic) ! ODE_IRK integrator
82+
x2 = integrator2%integrate(fcn, t, ic) ! ODE_AUTO integrator
83+
84+
! Display the number of solution points in each
85+
print '(AI0)', "ODE_IRK Solution Point Count: ", size(x1, 1)
86+
print '(AI0)', "ODE_AUTO Solution Point Count: ", size(x2, 1)
87+
88+
! ---------------------------- PLOTTING CODE ----------------------------- !
89+
! Plot the solution
90+
call plt%initialize()
91+
call plt%set_font_size(14)
92+
93+
xAxis => plt%get_x_axis()
94+
call xAxis%set_title("t")
95+
96+
yAxis => plt%get_y_axis()
97+
call yAxis%set_title("x(t)")
98+
99+
lgnd => plt%get_legend()
100+
call lgnd%set_is_visible(.true.)
101+
call lgnd%set_draw_border(.false.)
102+
call lgnd%set_draw_inside_axes(.false.)
103+
104+
call d1%set_name("IRK")
105+
call d1%set_draw_line(.false.)
106+
call d1%set_draw_markers(.true.)
107+
call d1%set_marker_style(MARKER_FILLED_TRIANGLE)
108+
call d1%set_marker_scaling(1.5)
109+
call d1%define_data(x1(:,1), x1(:,2))
110+
call plt%push(d1)
111+
112+
call d2%set_name("AUTO")
113+
call d2%set_draw_line(.false.)
114+
call d2%set_draw_markers(.true.)
115+
call d2%set_marker_style(MARKER_EMPTY_CIRCLE)
116+
call d2%set_line_color(CLR_RED)
117+
call d2%set_line_style(LINE_DASHED)
118+
call d2%define_data(x2(:,1), x2(:,2))
119+
call plt%push(d2)
120+
121+
call plt%draw()
122+
123+
call plt%clear_all()
124+
125+
call d1%define_data(x1(:,2), x1(:,3))
126+
call d2%define_data(x2(:,2), x2(:,3))
127+
call xAxis%set_title("x(t)")
128+
call yAxis%set_title("dx/dt")
129+
call plt%push(d1)
130+
call plt%push(d2)
131+
call plt%draw()
132+
133+
contains
134+
! Van Der Pol Equation
135+
! x" + x - mu * (1 - x**2) * x' = 0
136+
subroutine vdp(t, x, dxdt)
137+
real(real64), intent(in) :: t
138+
real(real64), intent(in), dimension(:) :: x
139+
real(real64), intent(out), dimension(:) :: dxdt
140+
141+
real(real64), parameter :: mu = 20.0d0
142+
143+
dxdt(1) = x(2)
144+
dxdt(2) = mu * (1.0d0 - x(1)**2) * x(2) - x(1)
145+
end subroutine
146+
end program
147+
```
148+
```text
149+
ODE_IRK Solution Point Count: 544
150+
ODE_AUTO Solution Point Count: 1283
151+
```
152+
These are the plots resulting from the above program.
153+
![](images/vanderpol_compare_example.png?raw=true)
154+
![](images/vanderpol_compare_example_diff.png?raw=true)
155+
156+
## Example 3
53157
The following example illustrates how to compute the solution to a system of ODEs modeling the bouncing of a ball. The example also utilizes the [FPLOT](https://github.com/jchristopherson/fplot) library in order to plot the solution.
54158
```fortran
55159
program example

0 commit comments

Comments
 (0)