Ejemplo n.º 1
0
"""

f2py.compile(prob_def_f, modulename='problemdef', verbose=0)
"""
Part 2

Using the compiled callback routines to solve the problem.
"""

import bacoli_py
import numpy
import time
from problemdef import f, bndxa, bndxb, uinit

# Initialize the Solver object.
solver = bacoli_py.Solver()

# Specify the number of PDE's in this system.
npde = 1

# Pack all of these callbacks and the number of PDE's into a
# ProblemDefinition object.
problem_definition = bacoli_py.ProblemDefinition(npde,
                                                 f=f._cpointer,
                                                 bndxa=bndxa._cpointer,
                                                 bndxb=bndxb._cpointer,
                                                 uinit=uinit._cpointer)

# Specify initial mesh, output_points and output_times.

# Set t0.
Ejemplo n.º 2
0
# Solving the nonlinear Schrodinger system.
# ------------------------------------------------------------------

import bacoli_py
import numpy

# Create Solver object. Here use the Runge-Kutta method for time
# integration and allow a large number of spatial subintervals to be
# used.
solver = bacoli_py.Solver(t_int='r', nint_max=2000)

# The number of PDEs in this system.
npde = 4

# Initialize problem-dependent parameters.
tempt1 = numpy.sqrt(6.0 / 5.0)
tempt2 = numpy.sqrt(2.0)


# Function defining the PDE system.
def f(t, x, u, ux, uxx, fval):

    fval[0] = -0.5*ux[0] - 0.5*uxx[1] - u[1]      \
        * ((u[0] * u[0] + u[1] * u[1]) + 2.0/3.0  \
        * ((u[2] * u[2] + u[3] * u[3])))

    fval[1] = - 0.5 * ux[1] + 0.5 * uxx[0] + u[0] \
        * ((u[0] * u[0] + u[1] * u[1]) + 2.0/3.0  \
        * ((u[2] * u[2] + u[3] * u[3])))

    fval[2] = 0.5 * ux[2] - 0.5 * uxx[3] - u[3]   \