docstr: Tests solving 3d diffusion equation.
docstr_tok: ["Tests","solving","3d","diffusion","equation","."]
code: def testAnisotropicDiffusion3d(self, boundary_condition):
      """Tests solving 3d diffusion equation."""
      # The equation is `u_{t} + Dx u_{xx} + Dy u_{yy} + Dy u_{zy} = 0`.
      # The final condition is a gaussian centered at (0, 0) with variance sigma.
      # The variance along each dimension should evolve as
      # `sigma + 2 Dx (t_final - t)` and `sigma + 2 Dy (t_final - t)`.
      grid = grids.uniform_grid(
          minimums=[-10, -20, -10],
          maximums=[10, 20, 10],
          sizes=[101, 111, 121],
          dtype=tf.float32,
      )
  
      zs = self.evaluate(grid[0])
      ys = self.evaluate(grid[1])
      xs = self.evaluate(grid[2])
  
      diff_coeff_x = 0.4  # Dx
      diff_coeff_y = 0.25  # Dy
      diff_coeff_z = 0.1  # Dz
      time_step = 0.1
      final_t = 1
      final_variance = 1
  
      def quadratic_coeff_fn(t, location_grid):
          del t, location_grid
          u_xx = diff_coeff_x
          u_yy = diff_coeff_y
          u_zz = diff_coeff_z
          # Specify mixed derivatives explicitly to trigger mixed discretization
          # matrix updater for the default boundary
          u_xy = 0
          u_zy = 0
          u_zx = 0
          return [
              [u_zz, u_zy, u_zx],
              [u_zy, u_yy, u_xy],
              [u_zx, u_xy, u_xx],
          ]
  
      final_values = tf.expand_dims(
          tf.reshape(_gaussian(zs, final_variance), [-1, 1, 1])
          * tf.reshape(_gaussian(ys, final_variance), [1, -1, 1])
          * tf.reshape(_gaussian(xs, final_variance), [1, 1, -1]),
          axis=0,
      )
      if boundary_condition == "default":
          bound_cond = [(None, None), (None, None), (None, None)]
      elif boundary_condition == "dirichlet":
          bound_cond = [
              (_zero_boundary, _zero_boundary),
              (_zero_boundary, _zero_boundary),
              (_zero_boundary, _zero_boundary),
          ]
      else:
          bound_cond = [
              (_zero_boundary, None),
              (None, _zero_grad_boundary),
              (_zero_boundary, _zero_grad_boundary),
          ]
      step_fn = douglas_adi_step(theta=0.5)
      result = fd_solvers.solve_backward(
          start_time=final_t,
          end_time=0,
          coord_grid=grid,
          values_grid=final_values,
          time_step=time_step,
          one_step_fn=step_fn,
          boundary_conditions=bound_cond,
          second_order_coeff_fn=quadratic_coeff_fn,
          dtype=grid[0].dtype,
      )[0]
  
      variance_x = final_variance + 2 * diff_coeff_x * final_t
      variance_y = final_variance + 2 * diff_coeff_y * final_t
      variance_z = final_variance + 2 * diff_coeff_z * final_t
      expected = tf.expand_dims(
          tf.reshape(_gaussian(zs, variance_z), [-1, 1, 1])
          * tf.reshape(_gaussian(ys, variance_y), [1, -1, 1])
          * tf.reshape(_gaussian(xs, variance_x), [1, 1, -1]),
          axis=0,
      )
  
      self._assertClose(self.evaluate(expected), result)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 2 for calling the MultidimParabolicEquationStepperTest obj's underlying member method code with example usage: obj.testAnisotropicDiffusion3d(boundary_condition) and returns: list