Skip to content

gpavanb1/FContin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FContin

Made with Love in India Downloads

Solve F(u, λ) = 0 over λ with just F!

This repository contains natural and pseudo-arclength/Euler-Newton continuation library using JAX for automatic differentiation, numdifftools for numerical differentiation using real or complex derivatives, and Pacopy

This enables automatic/numerical differentiation to obtain the Jacobian and derivative with respect to the parameter. GPU/TPU support is packaged as part of JAX.

How to install and execute?

Tested on Python 3.6.2 and pacopy 0.1.0

Just run

pip install fcontin

The following program illustrates a basic example

from fcontin.ContProblem import ContProblem

###
# Output record
###
lmbda_list = []
values_list = []

def callback(k, lmbda, sol):
    # Use the callback for plotting, writing data to files etc.
    lmbda_list.append(lmbda)
    values_list.append(sol)

###
# Define problem
###

def f(u, lmbda):
    """The evaluation of the function to be solved
    """
    return [
        u[0] + u[1] - (lmbda + 1.), u[0] - u[1] - lmbda
    ]

###
# Solving and Plotting
###

# Initial guess
u0 = [0., 0.]
# Initial parameter value
lmbda0 = 1.0

# Creating the problem
# Natural or Euler-Newton for cont_method
# Forward, Reverse, Numerical, Complex for jac_mode
problem = ContProblem(f, u0, lmbda0,
cont_method='Euler-Newton', 
jac_mode='Forward',
max_steps=10,
newton_tol=1e-10,
callback=callback
)

problem.solve()

Whom to contact?

Please direct your queries to gpavanb1 for any questions.