tanh_circle_10_rev_compare

← Unit Tests

Description

Compares no sharpening vs PM sharpening over 10 revolutions using the gif monitor with compare_fields and per-field sharpening control. Two fields share the same initial condition but only one has sharpening enabled.

How to run

python run.py unit_tests/tanh_circle_10_rev_compare.yaml

The YAML lives in unit_tests/; each run copies it into the timestamped run folder (original remains for easy re-running).

Config summary

  • Domain: 2D cell-centered, x,y ∈ [-0.5, 0.5], 100×100 points (dx = dy = 0.01)
  • Time: dt = 0.01, 2000 steps (T = 20 s, 10 revolutions)
  • CFL: 0.5
  • Velocity: (0.5, 0.0)
  • Fields:
    • alpha_no_sharp: radial tanh, sharpening: false
    • alpha_pm: radial tanh, sharpening: true (PM)
  • Solver: upwind_2d; Timestepper: euler
  • Sharpening: PM, eps_target 0.02, strength 1.0 (per-field control)
  • Monitors: console, gif with compare_fields (every 20 = 101 frames), individual GIFs

Key features demonstrated

  • Per-field sharpening: Each field can override the global sharpening setting with sharpening: true/false
  • Unified gif monitor: Using compare_fields overlays contour lines of multiple fields on the same plot for 2D

Output

Contour comparison GIF (101 frames). Use the slider to scrub through frames. Blue solid = no sharpening, red dashed = PM sharpening.

compare.gif

Individual field GIFs

No sharpening (alpha_no_sharp):

alpha_no_sharp.gif

PM sharpening (alpha_pm):

alpha_pm.gif

Config (YAML)

# Compare sharpening vs no sharpening over 10 revolutions
domain:
  x_min: -0.5
  x_max: 0.5
  n_points_x: 100
  y_min: -0.5
  y_max: 0.5
  n_points_y: 100

time:
  dt: 0.01
  n_steps: 2000   # 10 revolutions at CFL=0.5

velocity: [0.5, 0.0]

fields:
  - name: alpha_no_sharp
    initial_condition: "0.5 * (1 + tanh((0.15 - r) / 0.02))"
    boundary:
      type: periodic
    sharpening: false

  - name: alpha_pm
    initial_condition: "0.5 * (1 + tanh((0.15 - r) / 0.02))"
    boundary:
      type: periodic
    sharpening: true

solver:
  type: upwind

sharpening:
  enabled: false
  method: pm
  eps_target: 0.02
  strength: 1.0

output:
  monitors:
    - type: console
    - type: gif
      every_n_steps: 20   # 101 frames
      compare_fields:
        - field: alpha_no_sharp
          contour_levels: [0.5]
          color: blue
          linestyle: "-"
        - field: alpha_pm
          contour_levels: [0.5]
          color: red
          linestyle: "--"
    - type: gif
      every_n_steps: 20
      field: alpha_no_sharp
    - type: gif
      every_n_steps: 20
      field: alpha_pm