All Projects → rjrosati → SymbolicTensors.jl

rjrosati / SymbolicTensors.jl

Licence: MIT license
Manipulate tensors symbolically in Julia! Currently needs a SymPy dependency, but work is ongoing to change the backend to SymbolicUtils.jl

Programming Languages

julia
2034 projects

Projects that are alternatives of or similar to SymbolicTensors.jl

symbolic-pymc
Tools for the symbolic manipulation of PyMC models, Theano, and TensorFlow graphs.
Stars: ✭ 58 (+123.08%)
Mutual labels:  symbolic-computation, symbolic-math
Symbolics.jl
A symbolic math library written in Julia modelled off scmutils
Stars: ✭ 98 (+276.92%)
Mutual labels:  physics, symbolic-math
mathiu.cpp
mathiu : a simple computer algebra system in C++.
Stars: ✭ 58 (+123.08%)
Mutual labels:  symbolic-computation, symbolic-math
Metatheory.jl
General purpose algebraic metaprogramming and symbolic computation library for the Julia programming language: E-Graphs & equality saturation, term rewriting and more.
Stars: ✭ 266 (+923.08%)
Mutual labels:  symbolic-manipulation, symbolic-computation
phoebe
A high-performance framework for solving phonon and electron Boltzmann equations
Stars: ✭ 33 (+26.92%)
Mutual labels:  physics
cellpy
extract and tweak data from electrochemical tests of cells
Stars: ✭ 46 (+76.92%)
Mutual labels:  physics
mcSIM
Code for running a multicolor structured illumination microscopy (SIM) experiment using a DLP6500 digital micromirror device (DMD) and performing SIM reconstruction.
Stars: ✭ 19 (-26.92%)
Mutual labels:  physics
miepy
Python module to solve Maxwell's equations for a cluster of particles using the generalized multiparticle Mie theory (GMMT)
Stars: ✭ 24 (-7.69%)
Mutual labels:  physics
Legion-Engine
Rythe is a data-oriented C++17 game engine built to make optimal use of modern hardware.
Stars: ✭ 502 (+1830.77%)
Mutual labels:  physics
plottr
A flexible plotting and data analysis tool.
Stars: ✭ 32 (+23.08%)
Mutual labels:  physics
billiards
billiards physics
Stars: ✭ 37 (+42.31%)
Mutual labels:  physics
Py3ODE
Port of PyODE for Python 3
Stars: ✭ 29 (+11.54%)
Mutual labels:  physics
creative-coding-notebooks
🎨 An authorial collection of fundamental recipes on Creative Coding and Recreational Programming.
Stars: ✭ 17 (-34.62%)
Mutual labels:  physics
pem-dataset1
Proton Exchange Membrane (PEM) Fuel Cell Dataset
Stars: ✭ 48 (+84.62%)
Mutual labels:  physics
cas
Cellular Automata Simulator
Stars: ✭ 22 (-15.38%)
Mutual labels:  physics
SpinMonteCarlo.jl
Markov chain Monte Carlo solver for lattice spin systems implemented by Julialang
Stars: ✭ 35 (+34.62%)
Mutual labels:  physics
ux-animate
A simple but powerful tweening, spring physics, animation library for Rust
Stars: ✭ 19 (-26.92%)
Mutual labels:  physics
tikz
Random collection of standalone TikZ images
Stars: ✭ 87 (+234.62%)
Mutual labels:  physics
arpes
Mirror of PyARPES (gitlab/lanzara-group/python-arpes) the open source ARPES analysis framework
Stars: ✭ 21 (-19.23%)
Mutual labels:  physics
image-to-box2d-body
proof-of-concept game build pipeline for converting an image to a Box2D body
Stars: ✭ 24 (-7.69%)
Mutual labels:  physics

SymbolicTensors

Build Status codecov

Many numerical tensor manipulation packages exist (e.g. Einsum.jl), but treating tensors at a purely numeric level throws away a lot of potential optimizations. Often, it's possible to exploit the symmetries of a problem to dramatically reduce the calculation steps necessary, or perform some tensor contractions symbolically rather than numerically.

SymbolicTensors.jl is designed to exploit these simplifications to perform symbolic calculations and generate more efficient input into numeric tensor packages than you would write by hand. It based on SymPy.jl, sympy.tensor.tensor, xTensor, and ITensors.jl.

See the talk about this package given at JuliaCon 2020: https://www.youtube.com/watch?v=_b4JIv044GY

Example calculations

using SymbolicTensors
using SymPy

spacetime = TensorIndexType("spacetime","f")
@indices spacetime μ ν σ ρ η
x = TensorHead("x",[spacetime])
δ = spacetime.delta
# one way to write the metric on a sphere
g = 4*δ(-μ,-ν)/(1+x(μ)*x(ν)*δ(-μ,-ν))^2

# compute the christoffel symbols
Γ = (diff(g(-μ,-ν),x(σ)) - diff(g(-ν,-σ),x(μ)) + diff(g(-σ,-μ),x(ν)))/2
Γ = factor(contract_metric(canon_bp(Γ),spacetime.metric))

At this point Γ is a symbolic tensor expression, written in Einstein notation. It could represent 2 dimensional or 10,000 dimensional tensors in the same form -- this is one of the great advantages of working at the symbolic tensor level.

We could manipulate Γ further, or convert it into an array.

# convert Γ to Array{Sym}
xarr = symbols("x y",real=true)
garr = replace_with_arrays(g,Dict(x(ρ) => xarr, spacetime.delta(-ρ,-η) => [1 0; 0 1]))
Γarr = replace_with_arrays(Γ,Dict(x(ρ) => xarr, spacetime.delta(-ρ,-η) => [1 0; 0 1], spacetime => garr))

Now that we have an array in Γarr, Quote allows us to convert it into a native Julia function.

# Then Quote it and eval to a Julia function
quot = Quote("Christoffel",Γarr,[ x for x in xarr])
Christ = eval(quot)
Christ(0,1)

Rough TODO

  • Nicer errors
  • testing coverage
  • add conversion to ITensors or equivalent
  • documentation
  • symbolic derivatives?

known bugs

  • check issues
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].