Hi, I'm very new to the Dedalus project, and I'm working on solving the Navier-Stokes equations with Bousinesq approximation in an annulus geometry. The velocity field expressed as vec{u}=u \vec{e_theta} + v\vec{e_r}, and the boundary conditions are
u = v = 0 at r=Ri and r=Ro
\frac{\partial T}{\partial r} = 0 at r=Ri
T = (1-sin(\theta))/2 at r=Ro
phi, r = dist.local_grids(annulus)
sin = dist.Field(name='sin', bases=annulus.outer_edge)
sin['g']=np.sin(phi)
dr=lambda A: d3.radial(d3.grad(A)(r=Ri))
problem.add_equation("u(r=Ri) = 0")
problem.add_equation("u(r=Ro) = 0")
problem.add_equation("dr(T) = 0")
problem.add_equation("T(r=Ro) = (1-sin)/2")
Then it gives the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[42], line 6
4 while solver.proceed:
5 timestep = CFL.compute_timestep()
----> 6 solver.step(timestep)
7 if (solver.iteration-1) % 10 == 0:
8 max_Re = flow.max('Re')
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/solvers.py:654, in InitialValueSolver.step(self, dt)
652 self.warmup_time = wall_time
653 # Advance using timestepper
--> 654 self.timestepper.step(dt, wall_time)
655 # Update iteration
656 self.iteration += 1
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/timesteppers.py:596, in RungeKuttaIMEX.step(self, dt, wall_time)
594 # Compute F(n,i-1), only doing output on first evaluation
595 if i == 1:
--> 596 evaluator.evaluate_scheduled(iteration=iteration, wall_time=wall_time, sim_time=solver.sim_time, timestep=dt)
597 else:
598 evaluator.evaluate_group('F')
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/evaluator.py:92, in Evaluator.evaluate_scheduled(self, **kw)
90 """Evaluate all scheduled handlers."""
91 handlers = [h for h in self.handlers if h.check_schedule(**kw)]
---> 92 self.evaluate_handlers(handlers, **kw)
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/evaluator.py:111, in Evaluator.evaluate_handlers(self, handlers, id, **kw)
109 fields = self.get_fields(tasks)
110 self.require_coeff_space(fields)
--> 111 tasks = self.attempt_tasks(tasks, id=id)
113 # Oscillate through layouts until all tasks are evaluated
114 # Limit to 10 passes to break on potential infinite loops
115 n_layouts = len(self.dist.layouts)
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/evaluator.py:201, in Evaluator.attempt_tasks(tasks, **kw)
199 unfinished = []
200 for task in tasks:
--> 201 output = task['operator'].attempt(**kw)
202 if output is None:
203 unfinished.append(task)
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/future.py:226, in Future.attempt(self, id)
224 def attempt(self, id=None):
225 """Recursively attempt to evaluate operation."""
--> 226 return self.evaluate(id=id, force=False)
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/future.py:168, in Future.evaluate(self, id, force)
166 a.change_scales(a.domain.dealias)
167 if isinstance(a, Future):
--> 168 a_eval = a.evaluate(id=id, force=force)
169 # If evaluation succeeds, substitute result
170 if a_eval is not None:
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/future.py:168, in Future.evaluate(self, id, force)
166 a.change_scales(a.domain.dealias)
167 if isinstance(a, Future):
--> 168 a_eval = a.evaluate(id=id, force=force)
169 # If evaluation succeeds, substitute result
170 if a_eval is not None:
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/future.py:196, in Future.evaluate(self, id, force)
193 out.preset_scales(self.domain.dealias)
195 # Perform operation
--> 196 self.operate(out)
198 # Reset to free temporary field arguments
199 self.reset()
File ~/anaconda3/envs/dedalus3/lib/python3.12/site-packages/dedalus/core/arithmetic.py:250, in AddFields.operate(self, out)
248 # Set output layout
249 out.preset_layout(arg0.layout)
--> 250 np.add(arg0.data, arg1.data, out=out.data)
ValueError: non-broadcastable output operand with shape (1,1) doesn't match the broadcast shape (16,1)
I think I must do something wrong with the sin boundary condition, but I don't know how to fix it. Thank you so much for your help.
Best regards,
Chris Li