Code Documentation¶
-
class
measure.
Measure
(dom, w=None)[source]¶ - An instance of this class is a measure on a given set supp. The support is either
- a python variable of type set, or
- a list of tuples which represents a box in euclidean space.
- Initializes a measure object according to the inputs:
- dom must be either
- a list of 2-tuples
- a non-empty dictionary
- w must be a
- a function if dom defines a region
- left blank (None) if dom is a dictionary
-
boxCheck
(B)[source]¶ Checks the structure of the box B. Returns True id B is a list of 2-tuples, otherwise it returns False.
-
check
(dom, w)[source]¶ Checks the input types and their consistency, according to the __init__ arguments.
-
class
orthsys.
OrthSystem
(variables, var_range, env='sympy')[source]¶ OrthogonalSystem
class produces an orthogonal system of functions according to a suggested basis of functions and a given measure supported on a given region.This basically performs a ‘Gram-Schmidt’ method to extract the orthogonal basis. The inner product is obtained by integration of the product of functions with respect to the given measure (more accurately, the distribution).
To initiate an instance of this class one should provide a list of symbolic variables variables and the range of each variable as a list of lists
var_range
.To initiate an orthogonal system of functions, one should provide a list of symbolic variablesvariables
and the range of each these variables as a list of listsvar_range
.-
Basis
(base_set)[source]¶ To specify a particular family of function as a basis, one should call this method with a list
base_set
of linearly independent functions.
-
FormBasis
()[source]¶ Call this method to generate the orthogonal basis corresponding to the given basis via
Basis
method. The result will be stored in a property calledOrthBase
which is a list of function that are orthogonal to each other with respect to the measuremeasure
over the given rangeDomain
.
-
FourierBasis
(n)[source]¶ Generates a Fourier basis from variables consisting of all \(sin\) & \(cos\) functions with coefficients at most n.
-
PolyBasis
(n)[source]¶ Generates a polynomial basis from variables consisting of all monomials of degree at most
n
.
-
Series
(f)[source]¶ Given a function f, this method finds and returns the coefficients of the series that approximates f as a linear combination of the elements of the orthogonal basis.
-
SetMeasure
(M)[source]¶ To set the measure which the orthogonal system will be computed, simply call this method with the corresponding distribution as its parameter dm; i.e, the parameter is d(m) where m is the original measure.
-
TensorPrd
(Bs)[source]¶ Takses a list of symbolic bases, each one a list of symbolic expressions and returns the tensor product of them as a list.
-
-
class
interpolation.
Interpolation
(var, env='sympy')[source]¶ The
Interpolation
class provides polynomial interpolation routines in multi variate case.var is the list of symbolic variables and env is the the symbolic tool.
-
Delta
(idx=-1)[source]¶ Construct the matrix corresponding to idx‘th point, if idx>0 Otherwise returns the discriminant.
-
Interpolate
(points, vals)[source]¶ Takes a list of points points and corresponding list of values vals and return the interpolant.
Since in multivariate case, there is a constraint on the number of points, it checks for the valididty of the input. In case of failure, describes the type of error occured according to the inputs.
-
-
class
collocation.
Collocation
(variables, ufunc, env='sympy')[source]¶ The
Collocation
class tries to approximate the solutions of a system of partial differential equations with respect to an orthogonal system of functions.- To initiate an instance of this class one needs to provide two set of parameters:
- List of independent symbolic variables variables;
- List of unknown functions to be found that depend on the independent variables
ufunc
.
-
CollPoints
(pnts)[source]¶ Accepts alist of collocation point
pnts
, to form the algebraic system of equations and find the coefficients of the orthogonal functions fromOrthSystem.OrthBase
. Each point must be either a list or a tuple.
-
Equation
(eq)[source]¶ To enter the system of equations, use this meyhod with a list of equations as input.
-
PlugPoints
()[source]¶ Internal use: plug in collocation points to elliminate independent variables and keep the coefficients.
-
SetOrthSys
(obj, func)[source]¶ To approximate the solutions of the system of pdes, the class requires an orthogonal system of functions
OrthSystem
. This method accepts such a system.
-
Solve
()[source]¶ Solves the collocation equations and keep a dictionary of coefficients in
self.Coeffs
and returns a list of functions in the span of orthoginal system.
-
collocate
()[source]¶ Internal use: generates the system of equations for coefficients to be used via collocation points.
-
setSampleMeasure
(meas)[source]¶ Sets the measure over the domain for sampling collocation points in case of necessity.
-
setSolver
(solver, optn='lm')[source]¶ Currently only two solvers are supported:
- the sage`s defult solver for rather simple system of algebraic equations.
2. the scipy`s fsolves to handel more complex and larger systems. It also supports the following solvers from scipy:
- hybr
- lm (defauls)
- broyden1
- broyden2
- anderson
- krylov
- df-sane
-
class
subregion.
SubRegion
(collsys, num_parts=[])[source]¶ The SubRegion class partitions the region into sub-regions, solve the system of Integro-differential equations on each and glue them together.
- It takes:
- a collocation instance collsys;
- an optional list of positive integers num_parts which shows the number of equal length partitions for each variable.
-
AnalyseConditions
()[source]¶ Associates boundary conditions to each sub-collocation system. Starting from one corner, associates boundary conditions to all adjacent subregions based on the solution of the current subregion.
-
ClosedForm
(func)[source]¶ Compiles a piece-wise defined symbolic function from the solution for func which is an unknown from the original collocation system.
-
class
graphics.
Graphics
(env='numeric', numpoints=50)[source]¶ This class tends to provide basic graphic tools based on matplotlib and mayavi.
Accepts one optional argument env which determines the types of the function to be visualized:
- numeric: is a numerical function (regular python functions)
- sympy: Sympy symbolic function
- sage: Sage symbolic function
-
ParamPlot2D
(funcs, rng, color='blue', legend='', thickness=1)[source]¶ Appends a parametric curve to the Graphics object. The parameters are as follows:
funcs
: the tupleof functions to be plotted,rng
: a triple of the form (t, a, b), where t is the funcs‘s independents variable, over the range [a, b],color
: the color of the current curve,legend
: the text for the legend of the current crve.
-
Plot2D
(func, xrng, color='blue', legend='', thickness=1)[source]¶ Appends a curve to the Graphics object. The parameters are as follows:
- func: the function to be plotted,
- xrng: a triple of the form (x, a, b), where x is the func‘s independents variable, over the range [a, b],
- color: the color of the current curve,
- legend: the text for the legend of the current crve.
-
Plot3D
(func, xrng, yrng)[source]¶ Sets a surface to the Graphics object. The parameters are as follows:
func
: the function to be plotted,xrng
: a triple of the form (x, a, b), where x is the first func`s independents variable, over the range `[a, b],yrng
: a triple of the form (y, c, d), where x is the second func‘s independents variable, over the range [c, d].