ufjc.examples.error

An example module computing error as a function of stiffness.

This module contains a main function that allows the relative L2 error to be computed for each of the asymptotic approaches, where the approach to compare against is the exact approach, when available, and the numerical quadrature approach otherwise. The results are plotted using matplotlib. When executed at the command line, flags are passed as keyword arguments.

Example

Compute the relative L2 error when using the reduced and asymptotic approaches of approximating the isotensional single-chain mechanical response of the Morse-FJC model as a function of the nondimensional stiffness:

python -m ufjc.examples.error --potential 'morse'
main(**kwargs)[source]

Main function for the module.

This is the main function, called when executing the module from the command line, also available when importing the module.

Parameters:

**kwargs – Arbitrary keyword arguments. Passed to uFJC instantiation.

Example

Plot the relative L2 error for a few different potentials:

>>> import numpy as np
>>> from ufjc.examples import error
>>> error.main(potential='harmonic')
>>> error.main(potential='log-squared')
>>> error.main(potential='morse')
>>> error.main(potential='lennard-jones')
_images/ufjc-examples-error-1_00.png
_images/ufjc-examples-error-1_01.png
_images/ufjc-examples-error-1_02.png
_images/ufjc-examples-error-1_03.png

Example

Export .csv files for external use:

>>> from ufjc.examples import error
>>> error.main(potential='harmonic', csv=1)