Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gha3mi/forsolver
ForSolver - linear and nonlinear solvers
https://github.com/gha3mi/forsolver
complex-step-differentiation finite-difference-method fortran fortran-package-manager linear-system-solver newton-method newton-raphson nonlinear-systems quasi-newton-method solver
Last synced: 27 days ago
JSON representation
ForSolver - linear and nonlinear solvers
- Host: GitHub
- URL: https://github.com/gha3mi/forsolver
- Owner: gha3mi
- License: bsd-3-clause
- Created: 2023-06-21T20:26:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-03T16:56:25.000Z (11 months ago)
- Last Synced: 2024-02-04T15:11:16.358Z (11 months ago)
- Topics: complex-step-differentiation, finite-difference-method, fortran, fortran-package-manager, linear-system-solver, newton-method, newton-raphson, nonlinear-systems, quasi-newton-method, solver
- Language: Fortran
- Homepage: https://gha3mi.github.io/forsolver/
- Size: 886 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GitHub](https://img.shields.io/badge/GitHub-ForSolver-blue.svg?style=social&logo=github)](https://github.com/gha3mi/forsolver)
[![Version](https://img.shields.io/github/release/gha3mi/forsolver.svg)](https://github.com/gha3mi/forsolver/releases/latest)
[![Documentation](https://img.shields.io/badge/ford-Documentation%20-blueviolet.svg)](https://gha3mi.github.io/forsolver/)
[![License](https://img.shields.io/github/license/gha3mi/forsolver?color=green)](https://github.com/gha3mi/forsolver/blob/main/LICENSE)
[![Build](https://github.com/gha3mi/forsolver/actions/workflows/CI_test.yml/badge.svg)](https://github.com/gha3mi/forsolver/actions/workflows/CI_test.yml)**ForSolver**: A Fortran library of linear and nonlinear solvers.
## Usage
### Linear system solver
```fortran
use forsolver, only: solvex = solve(A,b,method)
```available methods (optional):
- ```gesv```
- ```gels```### Nonlinear system solver
```fortran
use forsolver, only: nlsolvercall nls%set_options(&
lin_method,&
nl_method,&
fdm_method,&
fdm_tol,&
cs_tol,&
TolFun,&
maxit,&
nmp,&
verbosity )call nls%solve(F, dFdx, x0, x_sol)
```available nl_methods:
- ```newton```
- ```newton-modified```
- ```newton-quasi-fd```
- ```newton-quasi-fd-modified```
- ```newton-quasi-cs```
- ```newton-quasi-cs-modified```fd: finite difference method
cs: complex step method
## Requirements
- A Fortran Compiler
- LAPACK, BLAS or MKL
- Fortran Package Manager (fpm)## fpm Dependency
If you want to use `ForSolver` as a dependency in your own fpm project,
you can easily include it by adding the following line to your `fpm.toml` file:```toml
[dependencies]
forsolver = {git="https://github.com/gha3mi/forsolver.git"}
```## Runing Tests
Execute the following commands to run tests with specific compilers:
```shell
fpm @-test
```
`compiler: ifx, ifort, gfortran, nvfortran`## Examples
### Example 1: Linear System Solver
```fortran
program example1use kinds
use forsolverimplicit none
real(rk), dimension(:,:), allocatable :: A
real(rk), dimension(:) , allocatable :: x, b
integer :: m,n, i, jm = 3
n = 2allocate(A(m,n),b(m),x(n))
A(1,:) = [ 1.0_rk, 5.0_rk]
A(2,:) = [ 3.0_rk, 1.0_rk]
A(3,:) = [-2.0_rk, 4.0_rk]b = [4.0_rk, -2.0_rk, 3.0_rk]
x = solve(A, b)
end program example1
```### Example 2: Newton's Method for Root Finding
```fortran
module my_function3
use kinds
implicit none
contains
function F1(x) result(F_val)
real(rk), intent(in) :: x
real(rk) :: F_val
F_val = 5.0_rk * x**3 + 8.0_rk * x - 5.0_rk
end function F1
function dF1dx(x) result(dFdx_val)
real(rk), intent(in) :: x
real(rk) :: dFdx_val
dFdx_val = 15.0_rk * x**2 + 8.0_rk
end function dF1dx
end module my_function3program example2
use forsolver
use my_function3implicit none
type(nlsolver) :: nls
real(rk) :: x, expected_xcall nls%set_options(&
nl_method = 'newton',&
maxit = 100,&
TolFun = 1e-4_rk,&
verbosity = 1)call nls%solve(F=F1, dFdx=dF1dx, x0=10.0_rk, x_sol=x)
end program example2
```## API Documentation
The most up-to-date API documentation for the master branch is available
[here](https://gha3mi.github.io/forsolver/).
To generate the API documentation for `ForSolver` using
[ford](https://github.com/Fortran-FOSS-Programmers/ford) run the following
command:```shell
ford ford.yml
```## Contributing
Contributions to `ForSolver` are welcome!
If you find any issues or would like to suggest improvements, please open an issue.