Skip to main content

SIMple Finite Element Methods in PYthon

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import pathlib, sys
simfempypath = str(pathlib.Path(__file__).parent.parent.parent)
sys.path.insert(0,simfempypath)

from simfempy.models.elliptic import Elliptic
from simfempy.applications.application import Application

#--------------------------------------------------------------
class HeatExample(Application):
    # nomen est omen
    def defineProblemData(self, problemdata):
        # boundary conditions
        problemdata.bdrycond.set(type="Dirichlet", colors=[1000, 3000])
        problemdata.bdrycond.set(type="Neumann", colors=[1001, 1002, 1003])
        problemdata.bdrycond.fct[1000] = lambda x, y, z: 200
        problemdata.bdrycond.fct[3000] = lambda x, y, z: 320
        # postprocess
        problemdata.postproc.set(name='bdrymean_right', type='bdry_mean', colors=1001)
        problemdata.postproc.set(name='bdrymean_left', type='bdry_mean', colors=1003)
        problemdata.postproc.set(name='bdrymean_up', type='bdry_mean', colors=1002)
        problemdata.postproc.set(name='bdrynflux', type='bdry_nflux', colors=[3000])
        # paramaters in equation
        problemdata.params.set_scal_cells("kheat", [100], 0.001)
        problemdata.params.set_scal_cells("kheat", [200], 10.0)
    # nomen est omen
    def defineGeometry(self, geom, h):
        h=0.2
        holes = []
        rectangle = geom.add_rectangle(xmin=-1.5, xmax=-0.5, ymin=-1.5, ymax=-0.5, z=0, mesh_size=h)
        geom.add_physical(rectangle.surface, label="200")
        geom.add_physical(rectangle.lines, label="20")  # required for correct boundary labels (!?)
        holes.append(rectangle)
        circle = geom.add_circle(x0=[0, 0], radius=0.5, mesh_size=h, num_sections=6, make_surface=False)
        geom.add_physical(circle.curve_loop.curves, label="3000")
        holes.append(circle)
        p = geom.add_rectangle(xmin=-2, xmax=2, ymin=-2, ymax=2, z=0, mesh_size=h, holes=holes)
        geom.add_physical(p.surface, label="100")
        for i in range(len(p.lines)): geom.add_physical(p.lines[i], label=f"{1000 + i}")

#--------------------------------------------------------------
heat = Elliptic(application=HeatExample(), fem='cr1')
result, u = heat.static()
print(f"{result=}")
fig = plt.figure(figsize=(10, 8))
fig.suptitle(f"{heat.application.__class__.__name__} (static)", fontsize=16)
outer = gridspec.GridSpec(1, 2, wspace=0.2, hspace=0.2)
heat.mesh.plot(fig=fig, outer=outer[0], bdry=True)
data = u.tovisudata()
data.update({'cell': {'k': heat.kheatcell}})
heat.mesh.plot(data=data, alpha=0.5, fig=fig, outer=outer[1])
plt.show()

Metadata

Release files for simfempy 2.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simfempy 2.2.9
File Size Uploaded Provenance Actions
simfempy-2.2.9.tar.gz 81.0 kB Without provenance Details for simfempy-2.2.9.tar.gz

Release files / simfempy-2.2.9.tar.gz

Download URL simfempy-2.2.9.tar.gz
Size 81.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e5a58d36fc21a8e7ea96b892431def96ec22201bc561ee8f19d7250d8794e38a
BLAKE2b-256 checksum
How to use checksums
fca7ffb1c6be924e9fdd7fd8ee6f908383f7b9a411c8033b9cffea78ba857405
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Security for simfempy 2.2.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.2.9 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page