- Notifications
You must be signed in to change notification settings - Fork6
A library for building finite difference simulations
License
NotificationsYou must be signed in to change notification settings
stefanmeili/FastFD
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A finite differences simulation library.
This package lets you quickly build simple numerical simulations.
- 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.
pip install fastfd
# Import fastfd and select the scipy sparse library (or cupy for GPU support)importfastfdasffdffd.sparse_lib('scipy')importnumpyasnp# Define axesx=ffd.LinearAxis('x',start=0,stop=1,num=201)y=ffd.LinearAxis('y',start=0,stop=1,num=201)# Define scalarsT=ffd.Scalar('T', [x,y],accuracy=4)# Define the modelmodel=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 conditionsmodel.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 modelresult=model.solve()
FastFD can be set to use the Cupyx sparse libraries, though support is still a little rough around the edges. The currentversion 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.
See example notebooks here: ./docs/examples for a more detailed explanation of how to use.
About
A library for building finite difference simulations
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.