Skip to content

Commit

Permalink
Merge pull request #1 from jchristopherson/Development-v1.1.0
Browse files Browse the repository at this point in the history
Development v1.1.0
  • Loading branch information
jchristopherson authored Mar 29, 2021
2 parents 2ab529c + db4b9d1 commit 3c90c31
Show file tree
Hide file tree
Showing 191 changed files with 17,830 additions and 3,262 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ before_install:
install:
- sudo apt-get install -qq gfortran-7
- sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-7 90
- sudo apt install git
- sudo apt install cmake
- sudo git clone https://github.com/jchristopherson/ferror.git
- pushd ferror
- sudo mkdir build
- pushd build
- sudo cmake -DCMAKE_INSTALL_LIBDIR=$HOME/.local/ferror ..
- sudo cmake
- sudo make
- sudo make install
- popd
- popd

before_script:
- mkdir build
Expand Down
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(integral C CXX Fortran)

# Define version information
set(INTEGRAL_MAJOR_VERSION 1)
set(INTEGRAL_MINOR_VERSION 0)
set(INTEGRAL_MINOR_VERSION 1)
set(INTEGRAL_PATCH_VERSION 0)
set(INTEGRAL_VERSION ${INTEGRAL_MAJOR_VERSION}.${INTEGRAL_MINOR_VERSION}.${INTEGRAL_PATCH_VERSION})

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

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

# By default, shared library
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

# Export all symbols on Windows when building shared libraries
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
Expand Down
106 changes: 105 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,112 @@ end program
```text
The solution is: 789.97089E-03, the integrator computed: 789.97089E-03.
```

## Example 2
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).
```fortran
program example
use iso_fortran_env
use integral_core
use fplot_core
implicit none
! Local Variables
type(ode_helper) :: fcn
type(ode_irk) :: integrator1
type(ode_auto) :: integrator2
procedure(ode_fcn), pointer :: ptr
real(real64) :: ic(2), t(2)
real(real64), allocatable, dimension(:,:) :: x1, x2
type(plot_2d) :: plt
type(plot_data_2d) :: d1, d2
class(plot_axis), pointer :: xAxis, yAxis
class(legend), pointer :: lgnd
! Set up the integrator
ptr => vdp
call fcn%define_equations(2, ptr)
! Define the initial conditions
t = [0.0d0, 8.0d1]
ic = [2.0d0, 0.0d0]
! Compute the solution
x1 = integrator1%integrate(fcn, t, ic) ! ODE_IRK integrator
x2 = integrator2%integrate(fcn, t, ic) ! ODE_AUTO integrator
! Display the number of solution points in each
print '(AI0)', "ODE_IRK Solution Point Count: ", size(x1, 1)
print '(AI0)', "ODE_AUTO Solution Point Count: ", size(x2, 1)
! ---------------------------- PLOTTING CODE ----------------------------- !
! Plot the solution
call plt%initialize()
call plt%set_font_size(14)
xAxis => plt%get_x_axis()
call xAxis%set_title("t")
yAxis => plt%get_y_axis()
call yAxis%set_title("x(t)")
lgnd => plt%get_legend()
call lgnd%set_is_visible(.true.)
call lgnd%set_draw_border(.false.)
call lgnd%set_draw_inside_axes(.false.)
call d1%set_name("IRK")
call d1%set_draw_line(.false.)
call d1%set_draw_markers(.true.)
call d1%set_marker_style(MARKER_FILLED_TRIANGLE)
call d1%set_marker_scaling(1.5)
call d1%define_data(x1(:,1), x1(:,2))
call plt%push(d1)
call d2%set_name("AUTO")
call d2%set_draw_line(.false.)
call d2%set_draw_markers(.true.)
call d2%set_marker_style(MARKER_EMPTY_CIRCLE)
call d2%set_line_color(CLR_RED)
call d2%set_line_style(LINE_DASHED)
call d2%define_data(x2(:,1), x2(:,2))
call plt%push(d2)
call plt%draw()
call plt%clear_all()
call d1%define_data(x1(:,2), x1(:,3))
call d2%define_data(x2(:,2), x2(:,3))
call xAxis%set_title("x(t)")
call yAxis%set_title("dx/dt")
call plt%push(d1)
call plt%push(d2)
call plt%draw()
contains
! Van Der Pol Equation
! x" + x - mu * (1 - x**2) * x' = 0
subroutine vdp(t, x, dxdt)
real(real64), intent(in) :: t
real(real64), intent(in), dimension(:) :: x
real(real64), intent(out), dimension(:) :: dxdt
real(real64), parameter :: mu = 20.0d0
dxdt(1) = x(2)
dxdt(2) = mu * (1.0d0 - x(1)**2) * x(2) - x(1)
end subroutine
end program
```
```text
ODE_IRK Solution Point Count: 544
ODE_AUTO Solution Point Count: 1283
```
These are the plots resulting from the above program.
![](images/vanderpol_compare_example.png?raw=true)
![](images/vanderpol_compare_example_diff.png?raw=true)

## Example 3
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.
```fortran
program example
Expand Down
Loading

0 comments on commit 3c90c31

Please sign in to comment.