I am new to coding and am working on using FEM to solve the wave equation with a fractional damping term and am having issues with defining a time dependent source term. This is the code I have for this based on a tutorial,
time = 0
tend=5
t = Parameter(0.0)
gausspt = (1 - t + ((math.pi)2)*(1-t+(1/2)*t2 - (1/6)t3) - (t(gamma))/(math.gamma(1-gamma)) + (t*(1-gamma))/(math.gamma(2-gamma)) -(t**(2-gamma))/(math.gamma(3-gamma)))*sin(math.pi * x) *sin(math.pi *y)
Draw(gausspt,mesh,“ft”)
while time < tend-dt/2.0:
time += dt
t.Set(time)
ft = LinearForm(fes)
ft += SymbolicLFI(gausspt*v)
(gamma is a predefined constant)
When I run this it produces an error ‘incompatible function arguments’. What do you suggest doing about this?
Note as well, that the linearform is built outside the loop and only reassembled inside, this saves the time to allocate/deallocate the vectors. Your version should work as well, but is less efficient.
from ngsolve import *
import math
from netgen.geom2d import unit_square
from time import sleep
gamma = 0.1
mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
fes = H1(mesh,order=2)
v = fes.TestFunction()
t = Parameter(0)
gausspt = (1 - t + ((math.pi)**2)*(1-t+(1/2)*t**2 - (1/6)*t**3)
-(t**(gamma))/(math.gamma(1-gamma)) + (t**(1-gamma))/(math.gamma(2-gamma))
-(t**(2-gamma))/(math.gamma(3-gamma)))*sin(math.pi * x) *sin(math.pi *y)
Draw(gausspt,mesh,"gausspt")
time = 0
tend = 5
dt = 1e-2
ft = LinearForm(fes)
ft += SymbolicLFI(gausspt*v)
while time < tend-dt/2:
time +=dt
t.Set(time)
Redraw()
sleep(0.1)
ft.Assemble()