Recent ionospheric observations indicate that the total electron content (TEC) may anomalously decrease or increase up to 5-20% before the occurrence of big earthquakes. The ionospheric density variations can be caused by earth surface charges/currents produced from electric currents associated with the stressed rock. We formulate a coupling model for the stressed rock-Earth surface charges-atmosphere-ionosphere system. The stressed-rock acts as the dynamo to provide the currents for the coupling system. The electric fields and currents in the atmosphere and the lower boundary of ionosphere are obtained by solving the current continuity equation, ∇ · J = 0, where J is the current density. A three-dimensional ionosphere simulation code is then used to study the ionospheric dynamics based on the obtained electric fields and currents. The simulation results show that a current density Jrock = 0.2-10 μA/m2 in an earthquake fault zone is required to cause daytime TEC variations of 2-25%. The simulation results also show that a current density Jrock = 0.01-1 μA/m2 can lead to nighttime TEC variations of 1-30% as well as the formation of a nighttime plasma bubble (equatorial spread F) extending over the whole magnetic flux tube containing the earthquake epicenter. We suggest that observations of daytime and nighttime TEC variations and a nighttime plasma bubble within the affected region can be used as precursors for earthquake prediction.