I was trying to simulate a modified vorticity equation, but I am facing some problems.
I have attached the complete script and the error message, please check it.
"""
2D IVP problem,
simulating modified form of Vorticity equation,
dt(curl(u)) - Dlap(curl(u)) + F = - (u.grad)curl(u)
where,
u= velocity field
D= diffusion coeff. = viscosity/density
F= forcing
initial condition : u(t=0)=f(x)
"""
import numpy as np
import matplotlib.pyplot as plt
import dedalus.public as d3
import logging
logger = logging.getLogger(__name__)
# Parameters
Lx,Ly = 1,10
Nx,Ny = 100,100
dealias = 3/2
stop_sim_time = 100
timestepper = d3.RK222
timestep = 0.01
dtype = np.float64
# Bases
coord = d3.CartesianCoordinates('x','y')
dist = d3.Distributor(coord, dtype=dtype)
xbasis = d3.RealFourier(coord['x'], size=Nx, bounds=(0, Lx), dealias=dealias)
ybasis = d3.RealFourier(coord['y'], size=Ny, bounds=(0, Ly), dealias=dealias)
# Fields
u = dist.VectorField(coord, name='u',bases=(xbasis,ybasis))
# Substitutions
D=1
# Initial conditions
x = dist.local_grid(xbasis)
y=dist.local_grid(ybasis)
u['g'][0]= np.sin(np.pi*x/Lx)
u['g'][1]=np.cos(np.pi*y/Ly)
F=2*np.sin(x)*np.cos(y)
# Problem
problem = d3.IVP([u], namespace=locals())
problem.add_equation("dt(skew(u)) - D*lap(skew(u)) + F = - u@grad(skew(u)) ")
# Solver
solver = problem.build_solver(timestepper)
solver.stop_sim_time = stop_sim_time
# Main loop
u.change_scales(1)
u_list = []
t_list = []
while solver.proceed:
solver.step(timestep)
if solver.iteration % 100 == 0:
logger.info('Iteration=%i, Time=%e, dt=%e' %(solver.iteration, solver.sim_time, timestep))
if solver.iteration % 25 == 0:
u.change_scales(1)
u_list.append(np.copy(u['g']))
t_list.append(solver.sim_time)
OUTPUT:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()