Skip to content

Commit

Permalink
Merge pull request #51 from pyccel/pip-install
Browse files Browse the repository at this point in the history
Clean up installation procedure with pip
  • Loading branch information
ratnania authored Nov 5, 2019
2 parents 85c698f + d0f8017 commit 5ac740f
Show file tree
Hide file tree
Showing 33 changed files with 250 additions and 419 deletions.
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,16 @@ before_install:
- h5pcc -showconfig -echo || true
- export CC="mpicc" HDF5_MPI="ON" HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/openmpi
- python -m pip install --upgrade pip
- python -m pip install -r requirements.txt
- python -m pip uninstall -y psydac
- python -m pip uninstall -y sympde
- python -m pip uninstall -y gelato
- python -m pip uninstall -y pyccel
- wget https://raw.githubusercontent.com/pyccel/pyccel/master/requirements.txt -O requirements_pyccel.txt
- python -m pip install -r requirements_pyccel.txt
- python -m pip install git+https://github.com/pyccel/pyccel@master
- wget https://raw.githubusercontent.com/pyccel/sympde/master/requirements.txt -O requirements_sympde.txt
- python -m pip install -r requirements_sympde.txt
- python -m pip install git+https://github.com/pyccel/sympde@master
- wget https://raw.githubusercontent.com/pyccel/gelato/master/requirements.txt -O requirements_gelato.txt
- python -m pip install -r requirements_gelato.txt
- python -m pip install git+https://github.com/pyccel/gelato@master
- python -m pip uninstall -y gelato
- python -m pip install -r requirements.txt

# command to install project
install:
- python -m pip install .
- python -m pip freeze

before_script:
- mkdir pytest
Expand Down
2 changes: 1 addition & 1 deletion TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ API

- add other solvers to the solver_driver (only cg is available now)

- remove psydac/run_tests.sh. however, we need to clear the cache of sympy after 1d, 2d and 3d tests, otherwise pytest will crash.
- however, we need to clear the cache of sympy after 1d, 2d and 3d tests, otherwise pytest will crash.

- add sympde and pyccel install procedure; maybe wget to download the requierements files as requirements_pyccel.txt etc then call pip3

Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions psydac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: UTF-8 -*-
__version__ = "0.1"
__all__ = ['api', 'cad', 'core', 'ddm', 'feec', 'fem',
__all__ = ['__version__', 'api', 'cad', 'core', 'ddm', 'feec', 'fem',
'linalg', 'mapping', 'utilities']

from psydac.version import __version__

from psydac import api
from psydac import cad
from psydac import core
Expand Down
34 changes: 26 additions & 8 deletions psydac/api/ast/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from sympde.topology import ScalarField
from sympde.topology import VectorField
from sympde.topology import SymbolicExpr
from sympde.topology.space import ScalarTestFunction
from sympde.topology.space import element_of
from sympde.topology.space import ScalarFunctionSpace
from sympde.topology.space import VectorFunctionSpace
from sympde.topology.datatype import dtype_space_registry
from sympde.topology.derivatives import _logical_partial_derivatives

from pyccel.ast.core import IndexedVariable
Expand Down Expand Up @@ -35,6 +38,21 @@ def __new__(cls, space, mapping, discrete_boundary=None, name=None,
if not isinstance(mapping, Mapping):
raise TypeError('> Expecting a Mapping object')

#.....................................................................
# If vector space is of undefined type, we assume that each component
# lives in H1; otherwise we raise an error. TODO: improve!
if isinstance(space, VectorFunctionSpace):
if space.kind == dtype_space_registry['undefined']:
space = ScalarFunctionSpace(
name = space.name,
domain = space.domain,
kind = 'H1'
)
else:
msg = 'Cannot evaluate vector spaces of kind {}'.format(space.kind)
raise NotImplementedError(msg)
#.....................................................................

obj = SplBasic.__new__(cls, mapping, name=name,
prefix='eval_mapping', mapping=mapping,
is_rational_mapping=is_rational_mapping)
Expand Down Expand Up @@ -173,7 +191,7 @@ def _initialize(self):
weights_elements = []
if self.is_rational_mapping:
# TODO check if 'w' exist already
weights_pts = ScalarField(self.space, name='w')
weights_pts = element_of(self.space, name='w')

weights_elements = [weights_pts]

Expand Down Expand Up @@ -217,7 +235,7 @@ def _initialize(self):
# ...

# ...
Nj = ScalarTestFunction(space, name='Nj')
Nj = element_of(space, name='Nj')
body = []
init_basis = OrderedDict()
updates = []
Expand Down Expand Up @@ -364,7 +382,7 @@ def _initialize(self):
# ...

# ...
Nj = ScalarTestFunction(space, name='Nj')
Nj = element_of(space, name='Nj')
body = []
init_basis = OrderedDict()
init_map = OrderedDict()
Expand Down Expand Up @@ -503,7 +521,7 @@ def _initialize(self):
# ...

# ...
Nj = VectorField(space, name='Nj')
Nj = VectorField(space, name='Nj') # TODO: use 'element_of'
body = []
init_basis = OrderedDict()
init_map = OrderedDict()
Expand Down Expand Up @@ -666,7 +684,7 @@ def _initialize(self):
# ...

# ...
Nj = ScalarTestFunction(space, name='Nj')
Nj = element_of(space, name='Nj')
init_basis = OrderedDict()
init_map = OrderedDict()

Expand Down Expand Up @@ -860,7 +878,7 @@ def _initialize(self):
weights_elements = []
if self.is_rational_mapping:
# TODO check if 'w' exist already
weights_pts = ScalarField(self.space, name='w')
weights_pts = element_of(self.space, name='w')

weights_elements = [weights_pts]

Expand Down Expand Up @@ -905,7 +923,7 @@ def _initialize(self):
# ...

# ...
Nj = ScalarTestFunction(space, name='Nj')
Nj = element_of(space, name='Nj')
body = []
init_basis = OrderedDict()
atomic_exprs = self.elements + weights_elements
Expand Down
9 changes: 4 additions & 5 deletions psydac/api/ast/fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from sympde.topology.space import ProductSpace
from sympde.topology.space import ScalarTestFunction
from sympde.topology.space import VectorTestFunction
from sympde.topology.space import element_of
from sympde.topology.space import IndexedTestTrial
from sympde.topology.derivatives import _partial_derivatives
from sympde.topology.derivatives import _logical_partial_derivatives
Expand Down Expand Up @@ -617,13 +618,11 @@ def _initialize(self):
if is_bilinear or is_linear:
test_function = self.weak_form.test_functions
if not isinstance(test_function, (tuple, Tuple)):
test_function = [test_function]
test_function = Tuple(*test_function)
test_function = Tuple(test_function)

elif is_function:
test_function = ScalarTestFunction(self.weak_form.space, name='Nj')
test_function = [test_function]
test_function = Tuple(*test_function)
test_function = element_of(self.weak_form.space, name='Nj')
test_function = Tuple(test_function)

# creation of symbolic vars
if is_bilinear:
Expand Down
3 changes: 2 additions & 1 deletion psydac/api/ast/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sympde.topology.space import ScalarTestFunction
from sympde.topology.space import VectorTestFunction
from sympde.topology.space import IndexedTestTrial
from sympde.topology.space import element_of
from sympde.topology import ScalarField
from sympde.topology import VectorField, IndexedVectorField
from sympde.topology import Mapping
Expand Down Expand Up @@ -462,7 +463,7 @@ def rationalize_eval_mapping(mapping, nderiv, space, indices_quad):

# ... weights and their derivatives
# TODO check if 'w' exist already
weights = ScalarField(space, name='w')
weights = element_of(space, name='w')

weights_elements = [weights]
if nderiv > 0:
Expand Down
40 changes: 12 additions & 28 deletions psydac/api/tests/test_api_1d_compatible_spaces.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
# -*- coding: UTF-8 -*-

from sympy import pi, cos, sin, Tuple, Matrix
from sympy import pi, sin
from scipy.sparse.linalg import spsolve

from sympde.core import Constant
from sympde.calculus import grad, dot, inner, cross, rot, curl, div
from sympde.calculus import laplace, hessian
from sympde.topology import (dx, dy, dz)
from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace
from sympde.calculus import dot, div
from sympde.topology import ScalarFunctionSpace
from sympde.topology import ProductSpace
from sympde.topology import element_of
from sympde.topology import Boundary, NormalVector, TangentVector
from sympde.topology import Domain, Line, Square, Cube
from sympde.topology import Trace, trace_0, trace_1
from sympde.topology import Union
from sympde.expr import BilinearForm, LinearForm
from sympde.expr import integral
from sympde.expr import Norm, TerminalExpr
from sympde.expr import find, EssentialBC


from psydac.fem.basic import FemField
from psydac.fem.vector import VectorFemField
from psydac.api.discretization import discretize

from numpy import linspace, zeros, allclose
from mpi4py import MPI
import pytest
from sympde.topology import Line
from sympde.expr import BilinearForm, LinearForm
from sympde.expr import integral
from sympde.expr import Norm
from sympde.expr import find

from scipy.sparse.linalg import cg, gmres
from scipy import linalg
from scipy.sparse.linalg import spsolve
from psydac.fem.basic import FemField
from psydac.api.discretization import discretize

import matplotlib.pyplot as plt
#==============================================================================

def run_system_1_1d_dir(f0, sol, ncells, degree):
Expand Down Expand Up @@ -76,7 +60,7 @@ def run_system_1_1d_dir(f0, sol, ncells, degree):

ah.assemble()

M = ah.linear_system.lhs.tosparse()
M = ah.linear_system.lhs.tosparse().tocsc()
rhs = ah.linear_system.rhs.toarray()
sol = spsolve(M, rhs)

Expand Down
54 changes: 18 additions & 36 deletions psydac/api/tests/test_api_2d_compatible_spaces.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
# -*- coding: UTF-8 -*-

from sympy import pi, cos, sin, Tuple, Matrix
import numpy as np
from sympy import pi, cos, sin, Matrix
from scipy import linalg
from scipy.sparse.linalg import spsolve

from sympde.core import Constant
from sympde.calculus import grad, dot, inner, cross, rot, curl, div
from sympde.calculus import laplace, hessian
from sympde.topology import (dx, dy, dz)
from sympde.calculus import grad, dot, inner, div
from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace
from sympde.topology import ProductSpace
from sympde.topology import element_of
from sympde.topology import Boundary, NormalVector, TangentVector
from sympde.topology import Domain, Line, Square, Cube
from sympde.topology import Trace, trace_0, trace_1
from sympde.topology import Union
from sympde.topology import Square
from sympde.expr import BilinearForm, LinearForm, integral
from sympde.expr import Norm, TerminalExpr
from sympde.expr import Norm
from sympde.expr import find, EssentialBC


from psydac.fem.basic import FemField
from psydac.fem.vector import VectorFemField
from psydac.fem.basic import FemField
from psydac.fem.vector import VectorFemField
from psydac.api.discretization import discretize

from numpy import linspace, zeros, allclose
import numpy as np
from mpi4py import MPI
import pytest

from scipy.sparse.linalg import cg, gmres
from scipy.sparse.linalg import spsolve
from scipy import linalg

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import animation
#==============================================================================

def run_system_1_2d_dir(f0, sol, ncells, degree):
Expand Down Expand Up @@ -83,7 +67,7 @@ def run_system_1_2d_dir(f0, sol, ncells, degree):

# ...
ah.assemble()
M = ah.linear_system.lhs.tosparse()
M = ah.linear_system.lhs.tosparse().tocsc()
rhs = ah.linear_system.rhs.toarray()
x = spsolve(M, rhs)
# ...
Expand Down Expand Up @@ -194,23 +178,21 @@ def run_system_2_2d_dir(f1, f2,u1, u2, ncells, degree):
# SERIAL TESTS
###############################################################################

def test_api_system_1_2d_dir_1():
from sympy.abc import x,y

f0 = -2*(2*pi)**2*sin(2*pi*x)*sin(2*pi*y)
u = sin(2*pi*x)*sin(2*pi*y)
x = run_system_1_2d_dir(f0,u, ncells=[10,10], degree=[2,2])

#==============================================================================
def test_api_system_2_2d_dir_1():
from sympy.abc import x,y
from sympy import cos


f1 = -x**2*(x - 1)**2*(24*y - 12) - 4*y*(x**2 + 4*x*(x - 1) + (x - 1)**2)*(2*y**2 - 3*y + 1) - 2*pi*cos(2*pi*x)
f2 = 4*x*(2*x**2 - 3*x + 1)*(y**2 + 4*y*(y - 1) + (y - 1)**2) + y**2*(24*x - 12)*(y - 1)**2 + 2*pi*cos(2*pi*y)
u1 = x**2*(-x + 1)**2*(4*y**3 - 6*y**2 + 2*y)
u2 =-y**2*(-y + 1)**2*(4*x**3 - 6*x**2 + 2*x)
p = sin(2*pi*x) - sin(2*pi*y)

x = run_system_2_2d_dir(f1, f2, u1, u2, ncells=[2**3,2**3], degree=[2,2])

def test_api_system_1_2d_dir_1():
from sympy.abc import x,y

f0 = -2*(2*pi)**2*sin(2*pi*x)*sin(2*pi*y)
u = sin(2*pi*x)*sin(2*pi*y)
x = run_system_1_2d_dir(f0,u, ncells=[10,10], degree=[2,2])

29 changes: 11 additions & 18 deletions psydac/api/tests/test_api_2d_scalar.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
# -*- coding: UTF-8 -*-

from mpi4py import MPI
from sympy import pi, cos, sin
from sympy.utilities.lambdify import implemented_function
import pytest

from sympde.core import Constant
from sympde.calculus import grad, dot, inner, cross, rot, curl, div
from sympde.calculus import laplace, hessian
from sympde.topology import (dx, dy, dz)
from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace
from sympde.topology import ProductSpace
from sympde.calculus import grad, dot
from sympde.calculus import laplace
from sympde.topology import ScalarFunctionSpace
from sympde.topology import element_of
from sympde.topology import Boundary, NormalVector, TangentVector
from sympde.topology import Domain, Line, Square, Cube
from sympde.topology import Trace, trace_0, trace_1
from sympde.topology import NormalVector
from sympde.topology import Square
from sympde.topology import Union
from sympde.expr import BilinearForm, LinearForm, integral
from sympde.expr import Norm
from sympde.expr import find, EssentialBC
from sympde.expr import BilinearForm, LinearForm, integral
from sympde.expr import Norm
from sympde.expr import find, EssentialBC

from psydac.fem.basic import FemField
from psydac.fem.basic import FemField
from psydac.api.discretization import discretize

from numpy import linspace, zeros, allclose
from mpi4py import MPI
import pytest


#==============================================================================
def run_poisson_2d_dir(solution, f, ncells, degree, comm=None):

Expand Down
Loading

0 comments on commit 5ac740f

Please sign in to comment.