then I start heating up the parameters of the shield, and slow the cooling rate, but how can I do?:idk:
double atmTemp = 0.5*(GetAtmDensity()*(GetAirspeed()*GetAirspeed()*GetAirspeed()));
That is already wrong - the formula is correct, but it does not give you temperature, but the so-called heat flux - the power flux in Watts per square meter that is produced by your spacecraft passing through the air.
It is one part of the heat balance of your spacecraft (incoming and outgoing energy). If you integrate the balance sum over the length of one time step (adding is already getting you close, but a RK-4 is more accurate), you get the internal energy of one section your heat shield (in Joule per square meter). The temperature of your heat shield can then be approximated by heat capacity and the color and intensity of your glow can be calculated by the blackbody radiation laws - which can be done good enough by a simple look-up table (energy to glow).
It all sounds maybe a bit like black magic here, but in actual code, depending on how accurate you want to be, you can do it pretty easily. how the energy transfers from the air to your heat shield is just a single formula that contains the heat flux in it, but also models conduction...
There it is:
all variables with the infinity symbol are the state of the free-stream airflow - density, temperature and velocity.
Tw is the current heat shield/wall temperature of your spacecraft.
cp and cH are design parameters of your spacecraft, they model how the heat transfers to the spacecraft heat shield.
(If you sort things a bit in your head, you can maybe see that this formula is actually just a simplification of the sum of the heat flux that makes your spacecraft hot (first part), with the heat flux that makes your spacecraft cold by conduction (second part) )