#!/usr/bin/env python3
import math
import json

# Physics Constants
r0 = 5e-4 # Initial Bubble Radii
L = 12*r0 # Length of Domain
ps=35.3e6 # Shock overpressure

# Grid/Time discretisations
Ny = 120 # Number of cells in y direction
Nx = Ny*2 # Number of cells in x direction
Tend = 1e-5 # End of Simulation
dt = 1e-8 # Same number of time steps as DEM
Nt = int(Tend/dt)

# Configuring case dictionary
print(
    json.dumps(
        {
            # Logistics
            "run_time_info": "T",
            # Computational Domain Parameters
            "x_domain%beg": -L/2.0,
            "x_domain%end": L/2.0,
            "y_domain%beg": 0.0,
            "y_domain%end": L*1.25,
            "m": int(Nx),
            "n": int(Ny),
            "p": 0,
            "cyl_coord": "T",
            "dt": dt,
            "t_step_start": 0,
            "t_step_stop": Nt,
            "t_step_save": 1,
            # Simulation Algorithm Parameters
            "num_patches": 3,
            "model_eqns": 1,
            "alt_soundspeed": "F",
            "mixture_err": "T",
            "time_stepper": 3,
            "weno_order": 5,
            "weno_eps": 1.0e-16,
            "weno_Re_flux": "F",
            "weno_avg": "F",
            "mapped_weno": "T",
            "null_weights": "F",
            "mp_weno": "F",
            "riemann_solver": 2,
            "wave_speeds": 1,
            "avg_state": 2,
            "bc_x%beg": -6,
            "bc_x%end": -6,
            "bc_y%beg": -2,
            "bc_y%end": -6,
            # Formatted Database Files Structure Parameters
            "format": 1,
            "precision": 2,
            "prim_vars_wrt": "T",
            "parallel_io": "T",
            # Patch 1: Background
            "patch_icpp(1)%geometry": 3,
            "patch_icpp(1)%x_centroid": 0.0,
            "patch_icpp(1)%y_centroid": 1.25*0.5*L,
            "patch_icpp(1)%length_x": L,
            "patch_icpp(1)%length_y": 1.25*L,
            "patch_icpp(1)%vel(1)": 0.0,
            "patch_icpp(1)%vel(2)": 0.0,
            "patch_icpp(1)%pres": 1e5,
            "patch_icpp(1)%rho": 998,
            "patch_icpp(1)%gamma": 1.0e00/(6.68e00 - 1.0e00),
            "patch_icpp(1)%pi_inf": 4050e5,
            # Patch 2: Shocked state
            "patch_icpp(2)%geometry": 3,
            "patch_icpp(2)%alter_patch(1)": "T",
            "patch_icpp(2)%x_centroid": -L/4,
            "patch_icpp(2)%y_centroid": 1.25*0.5*L,
            "patch_icpp(2)%length_x": L/2,
            "patch_icpp(2)%length_y": 1.25*L,
            "patch_icpp(2)%vel(1)": 20.20,
            "patch_icpp(2)%vel(2)": 0.0,
            "patch_icpp(2)%pres": ps,
            "patch_icpp(2)%rho": 1010.5193,
            "patch_icpp(2)%gamma": 1.0e00/(6.68e00-1.0e00),
            "patch_icpp(2)%pi_inf": 4050e5,
            # Patch 3: Bubble
            "patch_icpp(3)%geometry": 2,
            "patch_icpp(3)%x_centroid": 3*r0,
            "patch_icpp(3)%y_centroid": 0.0e00,
            "patch_icpp(3)%radius": r0,
            "patch_icpp(3)%alter_patch(1)": "T",
            "patch_icpp(3)%vel(1)": 0.0,
            "patch_icpp(3)%vel(2)": 0.0,
            "patch_icpp(3)%pres": 1e5,
            "patch_icpp(3)%rho": 1.204,
            "patch_icpp(3)%gamma": 1.0e00/(1.4e00-1.0e00),
            "patch_icpp(3)%pi_inf": 0.0e00,
            # Fluids Physical Parameters
            "fluid_pp(1)%gamma": 1.0e00 / (6.68e00 - 1.0e00),
            "fluid_pp(1)%pi_inf": 4050e5,
            "fluid_pp(2)%gamma": 1.0e00 / (1.4e00 - 1.0e00),
            "fluid_pp(2)%pi_inf": 0.0e00,
        }
    )
)
