GithubHelp home page GithubHelp logo

jacobwilliams / nlesolver-fortran Goto Github PK

View Code? Open in Web Editor NEW
33.0 5.0 3.0 1.11 MB

Nonlinear Equation Solver with Modern Fortran

License: BSD 3-Clause "New" or "Revised" License

Fortran 100.00%
nonlinear-equation-solver fortran broyden-method newton-raphson nonlinear-equations fortran-package-manager lsqr lusol lsmr quasi-newton

nlesolver-fortran's Introduction

nlesolver-fortran

Nonlinear Equation Solver with Modern Fortran.

A basic Newton-Raphson type nonlinear equation solver for dense systems with m functions of n input variables.

A work in progress.

Status

Language CI Status GitHub release codecov last-commit

Features

  • Is object-oriented.
  • Works with square, under-determined, or over-determined systems.
  • Can use different methods to solve the linear system:
    1. LAPACK routines (dgesv or dgels) for dense systems: If n=m, uses dgesv (LU decomposition). If n/=m, uses dgels (if m>n uses QR factorization, if m<n uses LQ factorization).
    2. lsqr -- a conjugate-gradient type method for solving sparse linear equations and sparse least-squares problems.
    3. lusol -- A sparse LU factorization for square and rectangular matrices, with Bartels-Golub-Reid updates for column replacement and other rank-1 modifications.
    4. lsmr -- a conjugate-gradient type method for solving sparse linear equations and sparse least-squares problems
    5. The user can also provide a custom linear solver.
  • Has a Broyden update option (sparse and dense versions).
  • Has various line search options.
    • use a specified constant step size (0,1]
    • backtracking linesearch method
    • exact linesearch method using fmin minimizer
    • evaluate function at specified fixed points

Compiling

  • A Fortran Package Manager file is also included, so that the library and tests cases can be compiled with FPM. For example:
fpm build --profile release
fpm test --profile release

By default, the library is built with double precision (real64) real values. Explicitly specifying the real kind can be done using the following preprocessor flags:

Preprocessor flag Kind Number of bytes
REAL32 real(kind=real32) 4
REAL64 real(kind=real64) 8
REAL128 real(kind=real128) 16

For example, to build a single precision version of the library, use:

fpm build --profile release --flag "-DREAL32"

To use nlesolver within your fpm project, add the following to your fpm.toml file:

[dependencies]
nlesolver-fortran = { git="https://github.com/jacobwilliams/nlesolver-fortran.git" }

Or to use a specific version:

[dependencies]
nlesolver-fortran = { git="https://github.com/jacobwilliams/nlesolver-fortran.git", tag="1.1.0" }

Note that LAPACK is required to build. The fmin, lsqr, lusol, and lsmr libraries are also dependencies (which will be automatically downloaded by fpm).

Documentation

  • The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD.

License

  • The NLESolver-Fortran source code and related files and documentation are distributed under a permissive free software license (BSD-3).

References

See also

  • MINPACK -- Modernized Minpack: for solving nonlinear equations and nonlinear least squares problems
  • LUSOL Stanford University Systems Optimization Laboratory
  • qr_mumps -- a software package for the solution of sparse, linear systems on multicore computers.

nlesolver-fortran's People

Contributors

jacobwilliams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nlesolver-fortran's Issues

Compilation isn't working for me

Hey, so just as the github page says, I ran the command :

fpm build --profile release

Yet the compilation goes well until the part

Depuis https://github.com/jacobwilliams/LSMR

  • tag 1.0.0 -> FETCH_HEAD

After that I get the error :

cmd_build:model error:Key fortran is not allowed in package file
STOP 1

I am using Ubuntu 22.04 and gfortran 11.4.

Support for CMake

Hello,
first of all, thank you for the library.
I was wondering if it is possible to compile the library with CMake because i need to use the library for a personal project that has the dependencies already created with CMake.

Best wishes,
Nicola

single and quad precision

The LAPACK routines are only double precision, so this library isn't going to work when compiling with single or quad precision.

Using the solver without providing the jacobian

Hi,
Thanks for making your codes available. I'm trying to use them to solve a collocation problem. I wonder whether it is possible to avoid providing the jacobian of the function (ie letting your code computing it numerically). From the source code it looks like grad is mandatory. Is this the case?
Thanks and best,
Gianni

add topics

I suggest adding the topics nonlinear-equations, newton-raphson.

Segfault for large problems when using Broyden

This line

fjac = prev_fjac + &
    matmul((delf-matmul(prev_fjac,delx)),&
    transpose(delx))/delxmag2

will segfault on intel for a large problem (e.g., n=1406, m=1200).

What can we do about it?

OpenMP

It seem broken when using OpenMP on an Apple Silicon Mac:

fpm run halo_solver --profile release --flag "-O2 -fopenmp" -- examples/example.json

results in:

 ----------------------
 Solving...
 ----------------------
 
ITER                        NORM(X)                        NORM(F)
   1             8.4871544844105244             0.0000000000000000
 
 ----------------------
 Solution...
 ----------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.