I'm still learning how to use Dedalus, so I apologize if there is an easy answer to this. I've searched on this group, but I wasn't able to find a post I could use.
I'm trying to generate training data for the 1D burgers equation and want to add a randomized force term f(x,t). I have no issues adding a term f(t), but am struggling to implement a spatially and temporal dependent term. It's a snapshot of my overall code, but I've been using the below code:
################################ Bases #########################################
xcoord = d3.Coordinate('x')
dist = d3.Distributor(xcoord, dtype=dtype)
xbasis = d3.RealFourier(xcoord, size=grid, bounds=(x_min, x_max), dealias=dealias)
################################ Fields ########################################
u = dist.Field(name='u', bases=xbasis)
t = dist.Field(name='t')
############################# External Forcing #################################
seed = 0
k_min = 1
k_max = 3
rs = np.random.RandomState(seed)
a = 1 + rs.normal(0, 0.5)
omega = rs.uniform(-0.4, 0.4)
k_values = np.arange(k_min, k_max + 1)
k = rs.choice(k_values)
phi = rs.uniform(0, 2 * np.pi)
period = 2*np.pi
f = lambda x, t: a*np.sin(omega*t + (2 * np.pi * k * x) / period)
ext_force = ""
if forcing:
ext_force += " + f(x,t)" # Not sure what to put here either.
############################## Subsitutions ####################################
dx = lambda A: d3.Differentiate(A, xcoord)
################################ Problem #######################################
problem = d3.IVP([u], namespace=locals(), time='t')
equation = "dt(u) - eta*dx(dx(u)) = - u*dx(u)" + ext_force
problem.add_equation(equation)
How should I define the forcing function f(x,t)? It's just a sine function with two different parameters.