docstr: Test solving heat equation with various time marching schemes.
  
  Tests solving heat equation with the boundary conditions
  `u(x, t=1) = e * sin(x)`, `u(-2 pi n - pi / 2, t) = -e^t`, and
  `u(2 pi n + pi / 2, t) = -e^t` with some integer `n` for `u(x, t=0)`.
  
  The exact solution is `u(x, t=0) = sin(x)`.
  
  All time marching schemes should yield reasonable results given small enough
  time steps. First-order accurate schemes (explicit, implicit, weighted with
  theta != 0.5) require smaller time step than second-order accurate ones
  (Crank-Nicolson, Extrapolation).
docstr_tok: ["Test","solving","heat","equation","with","various","time","marching","schemes",".","Tests","solving","heat","equation","with","the","boundary","conditions","`","u","(","x",",","t=1",")","=","e","*","sin","(","x",")","`",",","`","u","(","-2","pi","n","-","pi","\/","2",",","t",")","=","-e^t","`",",","and","`","u","(","2","pi","n","+","pi","\/","2",",","t",")","=","-e^t","`","with","some","integer","`","n","`","for","`","u","(","x",",","t=0",")","`",".","The","exact","solution","is","`","u","(","x",",","t=0",")","=","sin","(","x",")","`",".","All","time","marching","schemes","should","yield","reasonable","results","given","small","enough","time","steps",".","First-order","accurate","schemes","(","explicit",",","implicit",",","weighted","with","theta","!","=","0.5",")","require","smaller","time","step","than","second-order","accurate","ones","(","Crank-Nicolson",",","Extrapolation",")","."]
code: def testHeatEquation_InForwardDirection(self):
      """Test solving heat equation with various time marching schemes.
  
      Tests solving heat equation with the boundary conditions
      `u(x, t=1) = e * sin(x)`, `u(-2 pi n - pi / 2, t) = -e^t`, and
      `u(2 pi n + pi / 2, t) = -e^t` with some integer `n` for `u(x, t=0)`.
  
      The exact solution is `u(x, t=0) = sin(x)`.
  
      All time marching schemes should yield reasonable results given small enough
      time steps. First-order accurate schemes (explicit, implicit, weighted with
      theta != 0.5) require smaller time step than second-order accurate ones
      (Crank-Nicolson, Extrapolation).
      """
      final_time = 1.0
  
      def initial_cond_fn(x):
          return tf.sin(x)
  
      def expected_result_fn(x):
          return np.exp(-final_time) * tf.sin(x)
  
      @dirichlet
      def lower_boundary_fn(t, x):
          del x
          return -tf.math.exp(-t)
  
      @dirichlet
      def upper_boundary_fn(t, x):
          del x
          return tf.math.exp(-t)
  
      grid = grids.uniform_grid(
          minimums=[-10.5 * math.pi],
          maximums=[10.5 * math.pi],
          sizes=[1000],
          dtype=np.float32,
      )
  
      def second_order_coeff_fn(t, x):
          del t, x
          return [[-1]]
  
      final_values = initial_cond_fn(grid[0])
  
      result = fd_solvers.solve_forward(
          start_time=0.0,
          end_time=final_time,
          coord_grid=grid,
          values_grid=final_values,
          time_step=0.01,
          boundary_conditions=[(lower_boundary_fn, upper_boundary_fn)],
          second_order_coeff_fn=second_order_coeff_fn,
      )[0]
  
      actual = self.evaluate(result)
      expected = self.evaluate(expected_result_fn(grid[0]))
      self.assertLess(np.max(np.abs(actual - expected)), 1e-3)
  
imports: import math
  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 12 for calling the ParabolicEquationStepperTest obj's underlying member method code with example usage: obj.testHeatEquation_InForwardDirection() and returns: tf, unknown, unknown, tf, list