How to use exact continuity in 2D cases?

Hi there,

I have a question on how to use the exact continuity in 2D cases.

My error message:

Error executing job with overrides: []
Traceback (most recent call last):
  File "cylinder_2d.py", line 191, in run
    slv.solve()
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/solver/solver.py", line 159, in solve
    self._train_loop(sigterm_handler)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/trainer.py", line 521, in _train_loop
    loss, losses = self._cuda_graph_training_step(step)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/trainer.py", line 702, in _cuda_graph_training_step
    self.loss_static, self.losses_static = self.compute_gradients(
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/trainer.py", line 54, in adam_compute_gradients
    losses_minibatch = self.compute_losses(step)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/solver/solver.py", line 52, in compute_losses
    return self.domain.compute_losses(step)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/domain/domain.py", line 133, in compute_losses
    constraint.forward()
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/domain/constraint/continuous.py", line 116, in forward
    self._output_vars = self.model(self._input_vars)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/graph.py", line 220, in forward
    outvar.update(e(outvar))
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/eq/derivatives.py", line 84, in forward
    grad_var = self.prepare_input(input_var, grad_sizes.keys())
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/eq/derivatives.py", line 72, in prepare_input
    return [input_variables[x] for x in mask]
  File "/usr/local/lib/python3.8/dist-packages/modulus-22.9-py3.8.egg/modulus/eq/derivatives.py", line 72, in <listcomp>
    return [input_variables[x] for x in mask]
KeyError: 'z'

My code:

How do I use the function “curl” in this 2D case?

Many thanks in advance.

Hi @jflatter

Right now the curl requires all three dimensions to calculate. I’m not sure if this would work (we have not tried exact continuity in 2D as far as I know), but you could feed in a constant z value of zero to all your inputs.

The easiest way to do this would be via the parameterization parameter in the constraint. A simple example of this can be seen in the wave example. Again, not sure if this will work properly but this would be a quick hack to try.