Simulating Dispersal of Protoplanetary Disks and Planetary Atmospheres with Consistent Radiation and Thermochemistry