Self-consistent radiation transfer and hydrodynamics is a very important but still under-explored field in computational astrophysics. In this talk, I will discuss some of the basic concepts of radiation hydrodynamics and equation of state (EoS). I will also present a novel 2D code, Guangqi, that can solve radiation hydrodynamics with a realistic EoS self-consistently. The code is thoroughly tested and applied to planet formation and stellar evolution. Accretion shocks and circumplanetary disks may exist in forming gas giants. By self-consistently modelling the radiation transfer and gas thermodynamics, we find that the molecular hydrogen may dissociate before being accreted, thus increase the initial entropy of the gas giants. In the meantime, a low temperature, low accretion rate, circumplanetary accretion disk may exist. For stellar evolution, people have detected a dozen of light-curves of luminous red novae (LRNe) as time-domain astronomy prospers. The progenitors of these LRNe could be close massive binary stars and the LRNe events are the manifestation of their merging processes. To better understand their radiation hydrodynamic process, we solve the radiation hydrodynamics and EoS self-consistently, and find that hydrogen recombination energy plays an important role in the shape of the light-curves of some LRNe, as well as the geometry of the merger's outflow.