Skip to content

Add the case for the P1 radiation with a python heat source tutorial - #90

Open
pragyaangaur wants to merge 2 commits into
su2code:developfrom
pragyaangaur:p1-radiation-python
Open

pragyaangaur wants to merge 2 commits into
su2code:developfrom
pragyaangaur:p1-radiation-python

Conversation

@pragyaangaur

Copy link
Copy Markdown

This adds multiphysics/P1_radiation_python/run.py, the case for a new tutorial on the website. The script heats a square air cavity with a rotated elliptical source applied through PYTHON_CUSTOM_SOURCE and runs it with or without the P1 radiation model, depending on the absorption coefficient given as its argument. The configuration is written by the script and the mesh is generated by SU2 with MESH_FORMAT= RECTANGLE, so no other files are needed.

The tutorial page is in a companion pull request on su2code.github.io. It follows the suggestion in su2code/SU2#3021. I ran the script with absorption coefficients of 0, 1 and 10 1/m on SU2 develop, both serially and on 4 MPI ranks.

This adds run.py for the tutorial on the P1 radiation model and PYTHON_CUSTOM_SOURCE. The script heats a square air cavity with an elliptical source set from python and runs with or without the P1 model, depending on the absorption coefficient given as its argument.
@bigfooted

Copy link
Copy Markdown
Contributor

Hi @pragyaangaur can you also put this in a regression test in su2, we have a tutorials.py regression script for this.

@bigfooted bigfooted left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the setup is correct: the source units, the energy index, the owned-node count and the MPI handling all check out. I ran run.py on 4 ranks:

k (1/m) its rms[h] T_max (K) TOTAL_HEATFLUX (W/m) source (W/m)
0 946 -9.04 325.69 15.808 15.708
1 5610 -9.00 324.57 14.961 15.708
10 8000 (limit) -8.25 319.58 10.913, still drifting 15.708

At k=0 the balance closes to 0.6%, which comes from sampling the ellipse at the nodes. With radiation on it does not close: TOTAL_HEATFLUX is conduction only, and the P1 wall flux Theta*(4 sigma Tw^4 - G) is not reported anywhere.

Action points:

  1. SU2 (separate PR): make TOTAL_HEATFLUX (and the per-marker HEATFLUX) include the P1 radiative wall flux when radiation is active. After that, the script's energy balance should close for every k.
  2. k=10 does not converge within 8000 iterations, and the heat flux is still changing. Fix the settings (CFL, CFL_NUMBER_RAD, linear solver) or drop k=10 from the tutorial. Also add RMS_RAD_ENERGY to CONV_FIELD, since the P1 residual stays around -5 while rms[h] reaches -9.
  3. Make the case runnable from TestCases/tutorials.py. TestCase edits ITER in a cfg_file on disk and passes that file name as argv[1], so float(sys.argv[1]) crashes, and the generated cfg would overwrite the edited one anyway. Ship a cavity.cfg, take its path from argv, and pass the absorption coefficient as a second argument (as in py_wrapper/custom_source_buoyancy). Then add a k=1 test with a small test_iter, checking the RMS residuals including RMS_RAD_ENERGY.
  4. Tutorial text: state that kL = 0.05 and 0.5 are for demonstration only, since real air is essentially transparent. Also explain the 0.6% gap at k=0.

The script now reads the config file from its first argument, as TestCase passes it, and takes an optional absorption coefficient as a second argument, for which it writes a copy of the config. The case converges on both the enthalpy and the P1 residual, and the run with an absorption coefficient of 10 1/m is dropped because the segregated coupling makes it converge very slowly.
@pragyaangaur

Copy link
Copy Markdown
Author

Thanks for the careful review. I have addressed all four points.

  1. Radiative wall flux. This is in Add the P1 radiative wall heat flux to TOTAL_HEATFLUX SU2#3048. CRadP1Solver now integrates the Marshak wall flux Theta*(G - 4*sigma*Tw^4) over the monitored walls, and TOTAL_HEATFLUX and TOTAL_HEATFLUX_ON_SURFACE include it when radiation is active. With it, the heat into the walls at k=1 is 15.807 W/m against 15.808 W/m at k=0, so the balance closes. The p1rad reference changes only in the heat flux.

  2. Convergence. I tried higher and fixed CFL, CFL_NUMBER_RAD from 1e2 to 1e8, and more linear iterations. The P1 residual fell at the same rate in every case, and pushing the flow CFL further diverged. At k=10 the gas to radiation exchange coefficient, 16 kappa sigma T^3, is about 250 W/m^3K, which is about 25 times the conduction scale k/L^2. Since the energy and P1 equations are solved one after the other, that coupling converges slowly whatever the settings. So I dropped k=10. The case now uses CONV_FIELD= RMS_ENTHALPY, RMS_RAD_ENERGY with CONV_RESIDUAL_MINVAL= -6. The P1 residual stays about four orders above rms[h], and at -6 the heat flux has settled to about 6e-5. k=1 converges in 8757 iterations, and k=0, checked on the enthalpy only at -9, converges in 935.

  3. Regression test. cavity.cfg is now shipped, run.py takes its path from argv[1], and an optional argv[2] overrides the absorption coefficient by writing a copy of the config. The test p1_radiation_python is added to tutorials.py in Add the P1 radiative wall heat flux to TOTAL_HEATFLUX SU2#3048, at test_iter 20 with the residuals of P, U, V, h and E_Rad and the heat flux. I ran it through TestCase with mpirun -np 2 and it passes. It depends on this PR being merged first.

  4. Tutorial text. Add a tutorial on P1 radiation with a python heat source su2code.github.io#236 now says that kL = 0.05 is for demonstration only, since real air is almost transparent. It explains that the 0.6 percent gap at k=0 is the source being applied to whole control volumes whose points lie inside the ellipse, so the discrete source is 15.808 W/m and the balance does close. The figure now compares k=0 and k=1 and shows the temperature difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants