Skip to main content

FastFD

A finite differences simulation library.

This package lets you quickly build simple numerical simulations.

Features

  • Quickly build finite difference simulations with an arbitrary number of domains, scalars, dimensions and boundary conditions.
  • Concise, clear syntax.
  • Build models for CPU or GPU using Scipy or Cupy sparse libraries.
  • Arbitrary derivative order and approximation accuracy.
  • Partial model updates minimize overheads in iterative solutions.
  • Implicit transient simulation.

Usage

# Import fastfd and select the scipy sparse library (or cupy for GPU support)
import fastfd as ffd
ffd.sparse_lib('scipy')

import numpy as np

# Define axes
x = ffd.LinearAxis('x', start = 0, stop = 1, num = 201)
y = ffd.LinearAxis('y', start = 0, stop = 1, num = 201)

# Define scalars
T = ffd.Scalar('T', [x, y], accuracy = 4)

# Define the model
model = ffd.FDModel([T])

# Set model governing equations (thermal diffusion)
model.update_equations({
    'Conductivity': ((T.d('x', 2) + T.d('y', 2)), 0),
})

# Set model boundary conditions
model.update_bocos({
    'Tx=1 adiabatic': (T.i[-1, :], T.d('x')[-1, :], 0),
    'Ty=1 adiabatic': (T.i[:, -1], T.d('y')[:, -1], 0),
    'Tx=0 sinewave': (T.i[0, :], T.i[0, :], 100 * np.sin(x.coords * 2*np.pi)),
    'Ty=0 sinewave': (T.i[:, 0], T.i[:, 0], -100 * np.sin(y.coords * 2*np.pi)),
})

# Solve the model
result = model.solve()

Model Solution

GPU

FastFD can be set to use the Cupyx sparse libraries, though support is still a little rough around the edges. The current version of Cupy (8.5) only supports a least squares solver ('lsqr') which is much slower than the default 'spsolve'. However, spsolve will be implemented in the upcoming release of Cupy 9.0.

Example Notebooks

See example notebooks here: ./docs/examples for a more detailed explanation of how to use.

Steady state heat conduction Transient 1D wave propagation Transient 2D wave propagation

Metadata

Release files for FastFD 0.1

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

Source distribution (sdist)

Source distribution for FastFD 0.1
File Size Uploaded
FastFD-0.1.tar.gz 351.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FastFD 0.1
File Interpreter ABI Platform
FastFD-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 364.4 kB

Release files / FastFD-0.1.tar.gz

Download URL FastFD-0.1.tar.gz
Size 351.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3526b07580e016d5e9c54756821111cc16e66d049fc50c8a2820687ab56d2910
BLAKE2b-256 checksum
How to use checksums
224f9d4a236899d774d46f6f42863228e31c2c5ac83719fae5345393ed67cabf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Release files / FastFD-0.1-py3-none-any.whl

Download URL FastFD-0.1-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b323eb48ca68f70809f78c0b9c167a88abfc7d14ca3464a7dba08ca2fdbf81ad
BLAKE2b-256 checksum
How to use checksums
82bb5561368690234c2cbfaa1205f9242e62ff33e4a5b82da2b21f47ada89cc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

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