No project description provided
Project description
PlanarPy
A fast hpFEA program for the membrane Poisson equation
c(Δu) = f
using variable order triangle elements (orders 120) with heterogeneous prefinement.
Installation
Use the package manager pip to install PlanarPy.
pip install planarpy
Usage
The Mesh object requires a list of point tuples, pts = [(x0,y0), (x1,y1), ...], a list triangle node tuples, cells = [(0,1,2), (2,5,6), ...], and a base power, pow = 2, to initialize.
Define groups using boolean functions. Always use both coordinates x,y for all function definitions. Groups are used to define Dirichlet boundary conditions and may also be used to set volume forces on part of the domain. If no group is chosen when setting a volume force, a default group is used.
from planarpy import Mesh, Dom, sin, cos
# it is up to the user to define points and cells
# either manually or by using a foreign library.
# here the domain is assumed to be [10, 10]x[10, 10]
mesh = Mesh(pts, cells, 1)
# define groups
outer = mesh.def_group(lambda x, y: x == 10. or x == 10. or y == 10. or y == 10.)
left_half = mesh.def_group(lambda x, y: x <= 0.)
# prefinement
mesh.adapt_p(left_half, 10)
# domain setup
dom = Dom(mesh)
# define Dirichlet boundary
dom.set_boundary(outer)
# get the amount of free and constrained degrees of freedom
pos_dofs, neg_dofs = dom.dofs()
# set material constant c
dom.set_consts(1.)
# set boundary condition, default is 0
dom.embed_bcond(lambda x, y: [sin(x) + cos(y)], outer)
# set force in the domain
dom.set_force(lambda x, y: [sin(x) + cos(y)])
# solve
dom.solve()
# measure error with an exact solution
err = dom.err(lambda x, y: [sin(x) + cos(y)])
Plotting
PlanarPy offers three functions in order to extract graphical data in the form of lines
# mesh plot
sys = dom.plot_sys()
# displacement plot with 5 segments per line
disp = dom.plot_disp()
# displacement plot with a given
# number of segments per line
smooth = dom.plot_smooth(50)
The functions return three lists, x, y, z, for line coordinates.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
PlanarPy is licensed under GNU LGPLv3.
This software relies on the PyO3 library under the Apache2.0 license for ffi and on the rayon crate under the MIT and Apache2.0 licenses for parallelism.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for planarpy0.0.2cp310cp310win_amd64.whl
Algorithm  Hash digest  

SHA256  b15fc681791071c07380f591a4ffa2ca15b1203f1c9d23aef12b1d913c9ad695 

MD5  fbf36cae0e9c10abd56524dae10e4132 

BLAKE2b256  13d44f377cea72c513ffbffd0a3d6ef58bd7d7471019d84f0bed27d9badcddcb 