Simulator for an oil well circulation system
BACKGROUND AND SUMMARY OF THE INVENTION 
     The invention disclosed in this application pertains to the simulation of a physical system for use in the training and study of the operation of the system. It more particularly deals with the simulation of a fluid circulation system of an oil well. 
     One of the most feared and dangerous conditions in the drilling of an oil well is a blowout. In this condition formation fluid, which can be oil, gas or water, escapes from the oil well directly into the atmosphere in an uncontrolled manner. The force of the escaping fluid can be so great that equipment is destroyed, rig personnel can be injured or killed, and, in the case of oil or gas, uncontrolled fires can result which are difficult, expensive, and hazardous to extinguish. 
     The initiation of a blowout condition starts with the introduction of formation fluid into the well bore. This normally occurs when the well is being drilled, or during a trip when the drill pipe is being pulled out of the well. This introduction of formation fluid is known as a well kick. If the initiation of a well kick is recognized in its early stages, corrective measures can be taken and the kick can be controlled before a dangerous condition develops. 
     Unfortunately, indications that a well kick has started can be very subtle, and may not be recognized. Therefore, it is important that drilling personnel be trained in the detection and control of well kicks to prevent blowouts. This is particularly important in offshore drilling operations where, if a blowout occurs, there is no place to go to escape the accompanying destruction and fire. 
     In the past, drilling personnel have been trained at special wells using actual equipment. Usually a kick of inert gas is introduced into the well through a tubing placed into the well for that purpose. It can be seen that such an installation is expensive, limited to the condition of that well, and requires that the students come to the well location for training. Also, because of the time required to circulate out a kick, the number of students who can be trained is limited. 
     A drilling well simulator, as reported in the March, 1972, issue of WORLD OIL, has been developed to train drilling personnel in the prevention of blowouts. However, this device is a complicated device which requires an experienced operator to initiate and control the progression of a well kick based on the student&#39;s actions by changing at least one parameter at an operator&#39;s panel during the training session. In addition, the device is limited, and cannot simulate all well circulation applications. 
     Computer programs have been written to calculate pressures and volumes in oil wells, but they will not create a real time display responsive to changes of simulated controls, and additionally must be run on large digital computers. Thus they can only be used where computer facilities are available. 
     The present invention is an apparatus for simulating the circulation system of an oil well and includes: manually adjustable control means for simulating the controls of the circulation system of an oil well; digital, programmable calculating means responsive to the adjustable control means for calculating the fluid pressure at a plurality of points in the circulation system; and display means for displaying the calculated pressures for selected points in the circulation system thereby simulating the operation of the circulation system. The calculator of the invention includes means for automatically calculating the pressure of an intersected formation to include a selected fractional portion of a time dependent, unrelated real number such that a sufficiently high pressure will be simulated in the formation to cause formation fluid to invade the well bore thus providing a well kick. 
     The display means responds to the invading fluid and the student&#39;s adjustment of the control means for simulating the response of an oil well during a well kick. Thus, the invention is capable of being used to train drilling personnel in the operation of a circulation system of an oil well during the normal drilling of an oil well, and also for the well during the receiving of a well kick. If the well kick is not handled properly, the simulator contains warning means to indicate that a blowout would have resulted, or that a physical limit of the system would have been exceeded had the oil well being simulated been operated in a similar manner. By altering the programming of the programmable calculator, the invention may simulate receiving a well kick while making a trip with the drill pipe, or may simulate a circulation system used for treating an oil well, such as in fracturing or acidizing the well. 
     The invention additionally includes automatic means for randomly simulating the failure of one or more of a plurality of components in the circulation system. The simulated failure may occur either independent from the well kick, or during the course of the well kick in order that the student may be trained in the recognition of a circulation system component failure, and the handling of a well kick in conjunction with a component failure. 
     The invention provides for the easy change of the data used by the programmable calculator in actual units of measure, and represented by digital values, thus providing a simulator which simulates a particular well and a given configuration of circulation system in that well. This allows the student to be trained to operate a given circulation system in a given well. The invention also provides a simulator which may be used to evaluate the optimum method for the circulation system configuration for a particular application in a particular oil well. 
     The invention also includes audio means to simulate the sounds of selected components of the circulation system, thereby adding realism to the simulation. 
     The programmable calculator of the invention includes calculating means which simulate the introduction of formation fluid from the formation into the well bore; and the expansion, if gas, and flow rate of the fluid as it is circulated in the oil well. Calculation means are also included which simulate the introduction of a subsequent volume of formation fluid if the circulation system is not utilized properly in the circulating out of the first volume of fluid. 
     The invention&#39;s use of a digital programmable calculating means provides a simulator which is inexpensive, is compact and portable, and which may be available for other purposes. 
    
    
     THE DRAWINGS 
     A brief description of the appended drawings follows: 
     FIG. 1 presents a schematic diagram of a typical circulation system in an oil well which the disclosed invention simulates. 
     FIG. 2 presents a choke control panel of the invention which contains the choke controls, mud weight control, standpipe and casing pressure gauges, cumulative pump stroke and pit volume change displays, and time frame, error alarm, and system control switches. 
     FIG. 3 presents a driller&#39;s control panel which contains the pump, kelly, annular preventer, and hydraulically controlled relief valve controls, and the penetration, relative flow rate guages, and a second standpipe pressure gauge. 
     FIG. 4 presents an electrical schematic diagram of the choke control of the invention. 
     FIG. 5 presents an electrical schematic diagram of the pump control of the invention. 
     FIG. 6 presents an electrical schematic diagram of a switch suitable for use as the kelly, annular preventer, and hydraulic controlled relief valve of the invention. 
     FIG. 7 presents a diagram of the communication interface system network between the programmable calculator and the choke and driller&#39;s panels of the invention. 
     FIGS. 8a, 8b and 8c, joined at connector points A, B and C, present a flow diagram of calculator routine BOSS-O which calculates flow constants and gradients, based on specified input data, for later use by the main simulation routine. 
     FIGS. 9a, 9b and 9c, joined at connector points A, B, C and D, present a flow diagram of calculator routine BOSS-M which controls the input and output of data between the choke control and driller&#39;s control panel for simulating the well circulation system represented by the data input into the BOSS-O routine of FIG. 8. 
     FIGS. 10a, 10b and 10c, joined at connector points A and B, present a flow diagram of a subroutine of routine BOSS-M for calculating the pressures at a plurality of points in the circulation system being simulated. 
     FIG.. 11 presents a schematic representation of an array of data registers in the calculator of the invention for accounting the volumes of the fluids in the drill string and annulus of the circulation system being simulated. 
     FIG. 12 presents an embodiment of the pulse shaping circuit of FIG. 4. 
     FIG. 13 presents an embodiment of the up/down counter of FIG. 4. 
     FIG. 14 presents an embodiment of the binary-to-BCD converter of FIG. 4. 
     FIG. 15 presents an embodiment of the digital counter of FIG. 5 for periodically reading pulses from a voltage controlled amplifier. 
     FIG. 16 presents an embodiment of the latch of FIG. 5. 
     FIG. 17 presents an embodiment of a digital-to-analog converter and smoothing circuit for converting a digitally represented value output by the calculator to an analog signal for display on a gauge, and whose amplitude changes smoothly from one value to another. 
    
    
     THE CIRCULATION SYSTEM TO BE SIMULATED 
     At this point it is appropriate to discuss the circulation system to be simulated. The purpose of the circulation system illustrated in FIG. 1 is to circulate drilling fluid, known as mud, through the oil well. The mud has several functions. Among other functions, the mud cleans the bottom of the hole and carries the cuttings made by the bit to the surface, it cools and lubricates the bit as the bit drills, and it controls the formation pressure by its own hydrostatic pressure thus holding formation fluids in the formation. 
     In FIG. 1, the well 10 is being drilled by bit 13 of the drill string. The drill string includes drill collar 14 and drill pipe 15. The drill string is rotated from the surface to cause the bit 13 to drill in response to the rotary action and the weight of the drill collars. A portion of the well is cased by casing 11 which has been cemented into place. 
     Mud is normally pumped down the center of the drill string, and through nozzles (not shown) in the bit 13 and back up to the surface in the well annulus 12 between the drill string and the walls of the well bore. The annulus 12 can be divided into two sections, the annulus in the open hole 4, and the annulus in the cased hole 3. 
     The mud is pumped from a mud pit 32 through a suction line 33 by mud pump 30, and into a standpipe 29. From the standpipe 29, the mud goes through a flexible kelly hose 28, into a swivel 27 which funnels the mud into a central passageway of the kelly 26. The kelly 26 is connected to the top section of drill pipe 15 such that the mud will flow through the kelly 26, into the drill pipe 15, and then into the oil well as described above. 
     The kelly 26 is a large, square or hexagonal pipe which transmits rotary torque from the rotary equipment of the rig to the drill string. When the kelly reaches the bottom of its stroke, it is disconnected from the drill pipe 15, and raised by lifting on the bail of the swivel 27. A new section of drill pipe is then added to the drill string, the kelly is connected to the new section, and drilling is resumed by again applying torque to the kelly. The swivel 27 is designed to provide a fluid tight seal between the kelly hose 28 and the kelly 26, while allowing the kelly to rotate. 
     The drill string extends through a blowout preventer stack, to be discussed later, and into the well bore. During normal drilling or circulating, mud travels up the annulus 12, flows through the blowout preventer stack, and out a mud return line 24 into a shale shaker 31. The shale shaker 31 separates the formation cuttings from the mud. The mud then returns to pit 32 for reuse. 
     The blowout preventer stack is many times topped with a bell nipple 23 to make insertion of the drill string easier. Fill line 22 is used to pump additional mud into the well to keep the hole full when the drill string is being removed, such as when the bit is replaced. 
     If the fluid pressure in the formation at any time during the drilling of an oil well exceeds the hydrostatic pressure of the mud, the well receives a well kick. For instance, if the bit cuts into a formation which contains fluid, such as gas, oil or salt water, whose pressure is higher than the hydrostatic pressure of the mud in the well bore 10, the formation fluid may begin to flow into the well bore 10. This is known as a well kick. 
     In most cases, the formation fluid will be lighter than the drilling fluid, and as more formation fluid displaces the drilling mud, the hydrostatic head will become less. This lower pressure will allow more formation fluid into the well bore and, unless remedial action is taken, will lead to a blowout condition in which formation fluid escapes uncontrolled from the formation and up the oil well to the surface. 
     A blowout condition can also occur as the drill string is removed from the well. If sufficient mud is not added to the oil well to replace the volume of the pipe being removed, the hydrostatic head of the mud can be lowered sufficiently to result in a blowout. Also, as the pipe is withdrawn, a lower pressure may result at the bottom of the hole because of the piston effect of the drill string moving in the hole. This condition is known as swabbing out the hole. If the pressure is reduced sufficiently, formation fluid will flow into the hole. 
     When a kick condition is detected, protective equipment in the blowout preventer stack is actuated to seal off the well annulus 12 to maintain control of the well. Seals in the pump 30 are provided to prevent back flow of the mud up the interior of the drill string. 
     An annular type blowout preventer 21 is provided near the top of the blowout preventer stack. This type of preventer can be imagined as a large rubber stopper with a hole in the center to provide for the passing of the drill string. When it is actuated, the stopper is hydraulically shoved into the annular space around the drill pipe 15 to seal off the well annulus. 
     Below the annular type preventer is located one or more ram type preventers 16 and 20. In this type preventer, rams converge on one another from opposite sides. Ram preventers may either have pipe rams or blind rams. In pipe rams, the head of the rams is designed with a concave face such that when they are closed, the pipe is gripped by the rams, and a fluid tight seal is established. Blind rams form a fluid tight seal against one another in case the pipe is not in the well when the kick is detected, or in case the pipe parts. 
     Below ram type preventer 20, is a drilling spool 17 which allows the connection of kill line 18 and choke line 19 into the stack. The kill line is provided to insert fluid into the well annulus 12 under high pressure after the blowout preventers above it are closed. 
     Choke line 19 has a hydraulically controlled valve 40 and a choke 41. Valve 40 is normally closed, and is opened when it is desired to maintain the annulus under pressure. The choke 41 maintains the well pressure with a variable opening that allows mud and formation fluid to be bled off. A gas separator 42 removes gas from the mud, and the mud is circulated through mud line 44 to the shale shaker 31, and then into the mud pit 32 for reuse. The gas separated from the mud flows through the gas line 43 and is removed from the rig site and disposed of safely. 
     When a well kick is detected, corrective action must be taken to prevent a blowout. When a well kick is detected, drilling is stopped, and the blowout preventers are closed. The well is now under control. The pressure in the well annulus will rise until the bottom hole pressure is equal to the formation pressure. At this point, no more formation fluid will flow into the hole. 
     By measuring the pressure in the well annulus by means of a gauge 47, and the standpipe by means of a gauge 46, the cause of the kick may be determined. If the hydrostatic pressure of the mud column in the well is not sufficient to contain the formation fluids, additives may be mixed with the mud to make it denser and thus increase the hydrostatic pressure of the mud at the bottom of the hole. This is known as weighting the mud. To control the well, the denser mud must be circulated into the well, and the original mud and formation fluid in the annulus must be removed to provide a continuous column of mud in the well with sufficient density to maintain the formation fluid in the formation. 
     This circulation procedure is known as circulating out a kick. If the formation fluid is gas, it must be allowed to expand as it rises. If the gas does not expand, its pressure at the surface will be equal to the pressure at the bottom of the hole, and will exceed the pressure limits of the surface equipment. 
     One method of circulating out a kick is known as the Driller&#39;s Method. In this method, the pump speed and choke are adjusted to maintain sufficient pressure in the borehole to control the well. The formation fluid is then circulated out. Denser mud is then mixed, and a second circulation is made to maintain control of the well. 
     Another method is the Wait-and-Weight Method. In this method, the denser mud is first mixed in the pit. When the mud is ready, only one circulation is needed to remove the formation fluid and the lower density mud from the well, and to replace the mud with the denser mud required to control the well. 
     When the well is again under control, the blowout preventers may be opened, and drilling may continue. 
     During normal drilling, or in the circulation out of a kick, a number of components of the circulation system could fail. Some of these conditions can include the plugging of the nozzles in the bit 13 restricting the normal circulation of mud, a washout in the drill pipe in which the drill pipe 15 develops a leak, and a malfunction in the pump 30 during the circulation out of a kick such that the pump will not maintain the pressure or volume needed to control the well. 
     Other circulation systems which might be used in an oil well include a cementing system, in which cement is pumped down the inside of the casing and up the annulus between the casing and the well bore to cement the casing in place; a treating system, in which various chemicals and fluids are pumped into the well and forced out into the formation to change its characteristics and production abilities; and, a production system, for removing the formation fluid during commercial production. 
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     FIG. 2 illustrates the choke panel 7 of the preferred embodiment. Push buttons 50, 51 and 52 represent time frame controls. Button 50 provides for running the invention at real time. Buttons 51 and 52 provide for a time factor of five times real time and ten times real time respectively. The buttons are illuminated so as to give a visual indication of the time frame of the simulation. 
     Error lights 53, 54, and 55 are illuminated when error conditions are sensed. Error light 53 is illuminated when the hydrostatic pressure of the mud is sufficiently high to cause the formation to break down, such as when the mud is too dense. The resulting condition is known as lost circulation. Error light 54 is illuminated when a maximum allowable pressure limit of the surface equipment has been exceeded. 
     Error light 55 is illuminated when a well kick has not been handled properly and a blowout would occur in the system being simulated. Loudspeaker 60 sounds a beeping sound when an error condition is sensed. 
     Gauge 61 displays the standpipe pressure calculated by the invention and simulates the pressure gauge 46 in the simulated system. Gauge 63 displays the casing pressure and simulates the pressure gauge 47 in the simulated system. 
     Gauge 62 displays the degree of opening of the choke and is responsive to the adjustment of choke rate control 66 and choke control switch 67. When choke control switch 67 is held at the open position, the choke simulation is opened at the rate set by rate control 66. When the choke control switch 67 is held at the closed position, the choke simulation is closed at the rate set by rate control 67. 
     Mud weight control 64 is used to change the density of the mud. The change is made by appropriate means such as knobs 65. 
     Cumulative pump strokes display means 71 displays a digital number representing a total number of pump strokes. The display is reset back to zero by pushing reset switch 56. Resetting display means 71 indicates to the programmable calculator of the invention that a circulation of a changed density of mud has started. The cumulative pump strokes displayed will then be an indication of the volume of new mud, pumped in this circulation. 
     The pit volume change display 72 displays the calculated change in volume in the mud in the pit. A change in volume is an indication that formation fluid is displacing mud in the well annulus. An alarm set value is placed in alarm set control 69 by knobs 70, and if alarm switch 68 is in the on position, a buzzer alarm will sound when the pit volume change exceeds the alarm set value. 
     Stop button 58 will freeze the simulator action, and start button 57 will restart the simulation at the same point. 
     A circuit is provided to play a noise signal over loudspeaker 59 when a gas bubble is being circulated through the choke. 
     Cable 73 and connector 74 connect the circuitry of choke panel 7 with appropriate circuitry to interface with the programmable calculator of the invention. 
     FIG. 3 illustrates the driller&#39;s panel 8 of the invention. A silhouette 77 of a blowout preventer stack is provided to orient the student as to the location of the devices being controlled. 
     A kelly switch 78 has an up and down position to indicate the position of the kelly. A delay is built into the switching function to simulate the actual delay in moving from one position to another. Small lights or light emitting diodes 119a and 119b are lighted to indicate whether the kelly is in the up or down position. 
     An annulus preventer switch 80 and a hydraulically controlled relief valve 84 are also provided. Switching delays are likewise provided in these switches to simulate the actual delays needed to move the annulus preventer and valve from one position to another. Lights such as light emitting diodes 81a, 81b, 85a and 85b are provided to give a visual presentation of the position of the preventer and valve. 
     A simulated penetration rate is displayed on gauge 75. An increase in penetration rate, known as a drilling break, is one of the first signs that the well is taking a kick. The relative flow rate gauge 76 displays the rate of the mud in the flow line 24 illustrated in FIG. 1, as calculated by the calculator of the invention. 
     The standpipe pressure gauge 83 displays the same pressure as displayed by gauge 61 on the choke panel. A pump rate control 86 is used to simulate the throttle of the mud pump 30 of FIG. 1. The gauge 82 displays the pump rate. Since the pump 30 is pumping against the pressure in standpipe 29, any increase in standpipe pressure will cause a decrease in the pump rate of the pump 30. The electronics of the pump control are designed to reflect this reaction. 
     Pump switch 87 reflects which pump unit is being used during the simulation. If the invention simulates a failure in one pump unit, the student, after recognizing a pump failure, can simulate switching to an auxiliary pump by changing switch 87. A thumper circuit is also controlled by pump rate control 86, and creates a thumping sound which is played over loudspeaker 79 to add realism to the simulation. An increase in the rate setting of control 86 causes a corresponding increase in the rate of the thumping sounds. 
     The cumulative pump stroke display 71 of the choke panel 7 counts the simulated pump strokes of the pump control circuit. The time frame switches 50, 51 and 52 multiplies the number of counts in display 71, but does not affect the pump rate. Thus the programmable calculator calculates the volume of mud of the multiplied pump strokes at the unmultiplied pump rate. This has the effect of reducing the time needed to complete a circulation. 
     The electronics of the driller&#39;s panel 8 is connected to the electronics of the choke panel 7 and the programmable calculator by appropriate means as illustrated by cable 88 and connector 89. 
     FIG. 4 presents a circuit diagram of the choke controls of choke gates, 7 of FIG. 2. Potentiometer 90 is adjusted by the choke rate control 66, and varies the input voltage to a voltage controlled oscillator 91. The pulses generated by the oscillator 91 in response to the voltage across potentiometer 90 are supplied to gates 94 and 95. Gates 94 and 95 are shown as OR gates; but, could be AND gates, depending on the design of signal shaping circuits 93. In the embodiment shown in FIG. 4, signal shaping circuits 93 supply a low signal level to the gate control line of the OR gates when the circuits 93 are grounded through switch 92. When signal shaping circuits 93 are ungrounded, a high signal level is supplied to the gate control line of the OR gates. If gates 94 and 95 were AND gates the signal shaping circuits 93 would supply a high signal level when grounded, and a low signal level when ungrounded. 
     Manual switch 92 represents the choke control 67 of the choke panel 7. When the switch is in the up position, which represents the open position of control 67, the gate control input of OR gate 94 will be low, and the data input will be receiving pulses from the voltage controlled oscillator 91. With switch 92 in the up position, the gate control input of OR gate 95 will be high, and the gate data input will be receiving pulses from the voltage controlled oscillator 91. It can then be seen that when the switch 92 is in the up position, pulses will be passed by gate 94 to the up/down counter 96 and gate 95 will be inhibited. 
     It can likewise be seen that when switch 92 is in the down position, which represents the close position of control 67, pulses will be passed by gate 95 to the up/down counter and gate 94 will be inhibited. Switch 92 is spring loaded such that when it is not manually held in either the up or down position, it will move to the middle position shown in FIG. 4 such that neither gate 94 nor 95 will pass pulses. 
     Gate 94 passes pulses to the positive terminal 330 of counter 96, causing the counter to count up. Gate 95 passes pulses to the negative terminal 331 of counter 96, causing the counter to count down. 
     Conductor 97 represents a reset path which prevents the counter from counting above a maximum number representing a fully open choke or below zero representing a fully closed choke. 
     It can thus be seen that adjusting rate control 66 adjusts potentiometer 90 which controls the rate at which up/down counter 96 counts. Holding choke control 67 in either the open or close position controls switch 92, thereby determining whether counter 96 will count up or down. 
     If counter 96 holds the count as a binary number, a suitable binary-to-BCD converter 98 may be used to supply a binary coded decimal output to output terminal 97 for use by the calculator of the invention. It will be understood that data lines 360 and 361 are multiconductor lines for the transmission of binary data. A suitable digital-to-analog converter 100 converts the decimal number of the up/down counter 96 to an analog voltage for display on choke position gauge 62. 
     FIG. 5 presents a diagram of the pump rate control 86 of the driller&#39;s panel 8. Adjustment of the pump rate control 86 adjusts the potentiometer 170 of FIG. 5. Adjustment of potentiometer 170 varies the positive terminal input voltage of the operational amplifier 101. 
     As explained above, an increase in the standpipe pressure will cause a decrease in the pump rate. For this reason the voltage across the standpipe pressure gauge 83 is also present at input terminal 120 of voltage divider 100. The output of voltage divider 100 is fed into the negative terminal of operational amplifier 101. 
     It can thus be seen that an increase in the standpipe pressure gauge voltage will cause a proportional increase in the voltage at the negative terminal of operational amplifier 101. The operational amplifier performs a subtracting function to subtract the output voltage of voltage divider 100 from the output voltage of potentiometer 170. 
     The output of operational amplifier 101 is thus a voltage which is proportional to the pump rate of the pump being simulated corrected for the effect of the pressure in the standpipe. This voltage is supplied to pump rate gauge 82. 
     The output voltage for operational amplifier 101 also drives voltage controlled oscillator 104. Oscillator 104 generates a train of pulses of preferably 0-150 H z  responsive to the voltage at its input terminal. A digital counter 102 counts and latches the pulses from oscillator 104, and supplies a binary coded decimal representation over a multiconductor data line to terminal 103 for use by the calculator of the invention. The latch circuit is controlled by a clock which takes a new reading each second to determine the number of pulses received per second. If the pulsed signal is divided by 60, the pulses will represent the strokes per minute of the pump being simulated. Dividers 105, 106 and 107 in series perform a division by 60 so that the pulses which appear at the input of a thumper circuit 116 represent the strokes per minute of the pump. The pulses counted by counter 102 can be divided by the calculator to give the correct strokes per second. 
     Thumper circuit 116 provides an audio beat to loud-speaker 89 in response to each pulse received at its input. Thus loudspeaker 89 will play audio beats in beats per minute which are responsive to the setting of pump rate control 86, and corrected for standpipe pressure. 
     It can be seen that if the total pulses are counted from the output of divider 107, a number will be given which represents the total number of strokes of the pump. If the total pulses are counted from the output of divider 106, the number of pulses will be the number of pump strokes times five. Similarly, if the total pulses are counted from the output of divider 105, the number of pulses represents the number of pump stokes times ten. Thus the gauge 82, the digital signal at terminal 103, and the audio beats from loudspeaker 89 will always represent the pump rate in strokes per minute. However, the cumulative number of pump strokes displayed by digital display 71 will depend on where in the circuit the pulses from oscillator 104 are counted. 
     Switches 171, 172 and 173 of FIG. 5 represent push buttons 50, 51 and 52 respectively as shown in FIG. 2. Latch 108 may be either a mechanical or an electronic latch circuit which will allow only one switch to be closed at a time. The preferred embodiment is that latch 108 is an electronic circuit which, when one of switches 171, 172 and 173 is momentarily closed, only one of gate control lines 174, 175 or 176 will have a high signal level, and the other two gate control lines will have a low signal level. 
     For example, if it is desired to run the simulation at five times real time, button 51 is pushed. This will momentarily close switch 172. Responsive to the closing of switch 172, latch circuit 108 will place a high signal level on gate control line 175, and will place a low signal level on gate control lines 174 and 176. In this manner switch 171 enables AND gate 111 and inhibits AND gates 109 and 110; switch 172 enables AND gate 110 and inhibits AND gates 109 and 111; and, switch 173 enables AND gate 109 and inhibits AND gates 110 and 111. 
     The output of AND gates 109, 110 and 111 are each connected to an OR gate 112. The output of OR gate 112 is in turn connected to counter 113 which counts the pulses it receives from OR gate 112. Thus the gate control line which is in the high state will determine which AND gate will pass pulses to OR gate 112. The output of the two AND gates which are inhibited will remain in a low state and, therefore, OR gate 112 will only pass the pulses from the enabled AND gate to counter 113. 
     Counter 113 will count the total pulses it receives to represent the cumulative pump strokes of the pump being simulated. A reset signal on reset conductor 115 will reset the counter to zero. The reset signal is generated responsive to reset button 56 on the choke panel 7. 
     A digital representation of the number in the counter 113 is available to the calculator of the invention by data terminal 114 and is also displayed on digital display 71 of FIG. 2. 
     Each of the time frame buttons 50, 51 and 52 is illuminated by a small light 118 which is switched on by the action of a transistor 117 whose base is connected to the gate control line. When the gate control line goes to the high state, transistor 117 is turned on and the light circuit is completed. A light emitting diode may be used in place of the lamps 118 shown. 
     FIG. 6 presents a diagram of the time delay switches used to simulate the activation of the kelly, the annular preventer, and the hydraulic relief valve. A double throw switch 121 is used to switch the negative input terminal of a comparator 125 from a positive voltage to a negative voltage. 
     Resistors 122 and 123, and capacitor 124 are sized such that the RC time constant gives the delay desired. The positive input terminal of comparator 125 is grounded in order that the voltage on the negative input terminal is compared to ground. 
     When switch 121 is changed from +15 to -15 volts, the voltage across capacitor 124 will begin to decrease as the capacitor is discharged. The rate of the voltage drop will depend on the size of resistors 122 and 123, and the size of capacitor 124. 
     When the voltage across capacitor 124 drops below ground voltage, the voltage at output terminal 126 will become positive, indicating that the apparatus being simulated has been activated. 
     When switch 121 is changed from -15 to +15 volts, the voltage across capacitor 124 will begin to rise as the capacitor is changed. When the voltage across capacitor 124 exceeds ground voltage, the voltage at the output terminal 126 will become negative, indicating that the apparatus being simulated has returned to its original position. 
     The voltage on output terminal 126 can also be used to turn lights off and to indicate the position of the simulated apparatus. In the preferred embodiment, when terminal 126 voltage is positive, one indicating light will be turned on and a second light will be turned off. When the terminal voltage is negative, the second light will be turned on and the first turned off. 
     For instance, in the case of the annular preventer, when the output voltage is positive, open light 81a will be on and the closed light 81b will be off. When the output voltage is negative, the closed light 81b will be on and the open light 81a will be off. 
     FIG. 12 represents one embodiment of pulse shaping circuit of FIG. 4. Terminal 310 is the input terminal connected to switch 92, and terminal 311 is the output terminal to one of the OR gates. A positive voltage is applied to terminal 312 which causes a sufficient voltage to appear at output terminal 311 to inhibit the connected OR gate. When terminal 310 is grounded, the output voltage will drop, thus enabling the OR gate. Resistors 313 and 314 are sized to insure proper operation of the OR gates. Capacitor 316, and a large capacitor 315, are included to dampen transients caused by the operation of the switch. 
     One embodiment of up/down counter 96 is shown in FIG. 13. Two integrated circuits are connected in series as shown to give eight bits. Positive lead 330 is connected to the up counting pin 5 of the first circuit 332, and negative lead 331 is connected to the down counting pin 4. The high order bit pin 7 of the second circuit 333 is connected to the reset pin 14 of both circuits as shown such that when the high order bit is turned on, both circuits will be reset and all bits will be turned off. 
     When the number goes negative in the desired circuits, all bits are turned on to show the complement of the number. It can be seen that if the pulses from OR gate 95 of FIG. 4 cause the counter to count below zero, all the bits will be turned on, and the high order bit will immediately reset the circuit and turn all the bits off. Thus if the number in the couter goes above 127, representing a fully open choke, the number will go to zero. If the counter counts down to zero, representing a fully closed choke, it will remain at zero until switch 92 is moved to the open position. Integrated circuit 74193 has the characteristics desired, and is connected in the manner shown in FIG. 13 to give one embodiment of the up/down counter 96 of FIG. 4. A suitable D/A converter 100 is integrated circuit MC1408L-8 sold by the Motorola Company. 
     FIG. 14 presents one embodiment of the binary-to-BCD converter 98 of FIG. 4. Three integrated circuits, 334, 335 and 336, are connected in such a manner that a binary input on the conductors of data line 360 will result in a binary coded decimal output on the conductor of data line 361. 
     A suitable integrated circuit for use in binary-to-BCD converter 95 is circuit 74185 when connected as shown in the embodiment of FIG. 14. 
     FIG. 15 presents one embodiment of the digital counter 102 of FIG. 5. The output pulses of generator 104 to be counted are applied to input terminal 381. These pulses are applied to three integrated circuits, 370, 371 and 372, which are connected in series as shown. A second set of integrated latch circuits, 373, 374 and 375, are connected to circuits 370, 371 and 372, respectively as shown. The latch circuits will not accept the bits on their inputs and show them on their outputs until the latch circuits receive a signal from conductor 379. 
     Circuits 370, 371 and 372 will reset, that is, turn all their bits off, when they receive a signal from conductor 380. A one second clock, 376, places a signal on 379 every second. Upon receipt of the signal, latch circuits 373, 374 and 375 turn on their outputs to correspond to the turned on bits at their input. 
     A delay circuit 378 gives the latch circuits sufficient time to turn on, typically 15 microseconds, and then places a signal on conductor 380, thereby resetting circuits 370, 371 and 372. A suitable integrated circuit for 370, 371 and 372 is integrated circuit 7490. A suitable latch circuit for circuits 373, 374 and 375 is circuit 7475. The circuits are connected in accordance with FIG. 14 for one embodiment of the digital counter 102 of FIG. 5. Integrated circuits 7490 in a similar configuration as circuits 370, 371 and 372 with a reset switch controlling conductor 380 may be used for resettable counter 113 of FIG. 5. 
     FIG. 16 shows one embodiment of latch 108 of FIG. 5. An integrated circuit 326 having AND gates 327 is used to place signal levels on gate control lines 174, 175 and 176. Pulse shaping circuits 319 are placed between switches 171, 172 and 173; and, latch control lines 320, 321 and 322 respectively. Pulse shaping circuits 319 are of the same type as that shown in FIG. 12. 
     AND gates 323, 324 and 325 are connected to latch circuit 326 and latch control lines 320, 321 and 322 in such a manner that the latch control line grounded through switches 171, 172 and 173 gives a low signal level to the other two latches as shown. It can thus be seen that closing one of the switches will cause a low signal level on the corresponding latch control line and the two other AND gates. The action of the latches will cause a high signal level on the corresponding gate control line, and will cause low signal levels on the other two gate control lines. The latches will maintain these signal relationships even after the switch is released and reopens. Latch circuit 74279 is suitable for integrated circuit 326. 
     FIG. 7 presents a diagram of the input-output interface between the calculator and the control panels of the invention. A suitable digital programmable calculator 130 is programmed to receive the various outputs of choke panel 7 and driller&#39;s panel 8; to calculate the pressures and volumes present at a plurality of points in the circulation system being simulated; and, to return digital values including various pressures and volumes to panels 7 and 8 for display. 
     Digital programmable calculator 130 is preferably a Wang Model 600-14TP Programmable calculator sold by Wang Laboratories of Tweksbury, Massachusetts. The discussion herein concerning the input-output interface between the calculator 130 and the control panels 7 and 8 will be in terms of the operating characteristics of the Wang 600 calculator. The specifications for interfacing with the Wang calculator are found in the publication Input/Output Interfacing Specifications Wang 600 Series, published by Wang Laboratories, Inc., July 1, 1973, which may be used by one skilled in the art for accomplishing the mentioned input-output interface. 
     Calculator 130 has an output means 131 and an input means 132 through which data and commands are passed between the calculator and peripheral devices. The control panels 7 and 8 have a common input-output or I/O circuit 139. Data from the calculator to the panels is passed through the I/O circuit 139 over multiconductor communication line 175 to the control panel input circuit 140. The control panel input circuit 140 buffers the data and places it on a multiconductor input data bus 143 as a binary coded decimal number which may be read by the peripheral device concerned. The control panel input circuit 140 also issues command pulses on command line 143 for controlling the acceptance of data by the proper device. 
     Data from the control panels to the calculator is passed through the I/O circuit from a control panel output circuit 141 over multiconductor communication line 176. The control panel output circuit 141 buffers data transmitted by the peripheral device desired and transmits the data serially, a digit at a time, through the I/O circuit 139 to the calculator input 132. The output circuit additionally generates calculator command characters at the completion of data transmission and in response to command signals on command line 142. 
     The I/O circuit 139, in addition to passing input and output data, also places the address of the device concerned on multiconductor address line 145, and generates a control signal on command line 181. 
     The address line 135 includes four conductors which transmit, under program control, a binary coded decimal number which represents the address of the peripheral device to be interfaced with the calculator. A fifth conductor in line 135 indicates whether the device address is in group one or group two. Group one is represented by a zero on the group line, and group two by a one on the group line. Then the device address consists of a group number and an address and may be numbered as shown in the upper right-hand corner of the devices of the embodiment shown in FIG. 7. The particular device being addressed by the calculator may be either an input device or an output device. In FIG. 7, devices 146-151 are panel output devices in group one and have addresses 0-5. Devices 154-160 are panel input devices in group one and have addresses 8-14. Devices 152, 153 and 161-163 are panel input devices in group two and have addresses 8-12. 
     The calculator output 131 addresses a device by placing an address on line 135, and then places a strobe signal on strobe line 180. I/O circuit 139 passes the address signals to address line 145. The I/O circuit 139 then delays the strobe signal on strobe line 180 for a short length of time, typically 15 microseconds, to allow the devices addressed to receive the address on line 145; and, then strobes command line 181. The device addressed then responds to the strobe on line 181 dependent on whether it is an input or an output device. If the device is an output device, it transmits its data; if it is an input device, it is enabled to receive data. All unaddressed devices ignore any following command and data signals. 
     A four conductor digit position line 134 transmits a binary coded decimal representing the digit location of the binary coded decimal being simultaneously transmitted over a four conductor digit value line 133. For instance, if the first digit of the number to be transmitted to the device in group one whose address is 13 has a value of 7, the address line 135 will contain the number 013, digit position line 134 will contain the number 1, and digit value line 133 will contain the number 7. After a set length of time, the next digit value and digit position will appear on lines 133 and 134 respectively. 
     During the serial transmission of a number by the calculator output 131, the calculator is in a stop state, and will not continue execution of its program until the calculator receives a go command. The entire number to be sent by the calculator is transmitted digit-by-digit as described above. If a go command is not received by the calculator, it will again send that number digit-by-digit until a go command is received. The calculator is restarted at any time by transmitting a go command to the calculator input 132. 
     Control panel input circuit 140 receives each digit of the number being transmitted and stores the digits in appropriate shift registers. When a decimal point code is transmitted, the input circuit 140 receives and latches one more digit, transfers the number in the shift registers to a latch circuit similar to that discussed, and then strobes command line 142. It should be noted that when the number is latched, the corresponding bit conductors in input bus 143 are turned on. The strobe on line 142 causes the device, previously enabled by the address and strobe on lines 181 and 145, to accept the number on input bus 143. The strobe on line 142 also strobes the control panel output circuit 141 causing it to generate a go command to restart execution of the calculator. 
     Input devices 152, 153 and 161-163 of group two are basically switches and thus no numerical data needs to be transferred. Thus when any of the devices in group two are addressed, the strobe pulse on command line 181 serves to operate the switches. 
     If one of the devices 161, 162 or 163 is addressed, light 53, 54 or 55 respectively is turned on, and an audible alarm sound is played over loudspeaker 60 of FIG. 2. The circuit of devices 161, 162 and 163 also are connected to the output circuit 141 such that when they are addressed, the output circuit 141 is pulsed. The pulse inhibits the generation of the next go command to the calculator, thereby preventing the calculator from continuing execution of the program after an error device has been addressed. The connection from devices 161, 162 and 163 to output circuit 141 is not shown to simplify FIG. 7. 
     Devices 146 to 151 are output devices which transmit data to the calculator of the invention. When one of the output devices is addressed and strobed, its data is placed on the multiconductor output bus 144. The control panel output circuit 141 then serially transmits the number requested digit-by-digit over line 176 to the I/O circuit 139. The I/O circuit places the binary coded decimal representation on data line 136. Strobe line 138 is then strobed causing the calculation input 132 to accept the digit. 
     When all digits of the number have been transmitted, all eight conductors of input line 137 and data line 136 are used to transmit a go command to the calculator. When the go command is placed on lines 136 and 137, strobe line 138 is strobed, and the calculator returns to program control. 
     The stop button 58 of choke panel is connected to output circuit 141 and inhibits the next go command from being transmitted. Thus the simulator will stop at the end of the next panel output operation. Start button 57 causes output circuit 141 to issue a go command and strobe line 138 to restart the program. 
     Output devices 148 and 151 only have an on or off position. Therefore, only one bit is needed to transmit the data. The full number, however, is still transmitted to calculator input 132. 
     FIG. 17 presents an embodiment of the digital-to-analog converter used in input devices 154-157 to convert the digital data on input data bus 143 to a voltage signal for display on the appropriate gauge. Device 154 displays casing pressure on gauge 63; device 155 displays standpipe pressure on gauges 61 and 83; device 156 displays flow rate on gauge 76; and, device 157 displays penetration rate on gauge 75. Each of these devices uses a digital-to-analog converter 341 to convert the digital data on input data bus 143 to an analog voltage signal. The input data bus 143 is connected to the input terminals 340 of the converter. It should be remembered that input data bus 143 and input terminals 340 are multiconductor and multipin connections. A suitable converter is a DAC4912D sold by the Datel Company. 
     After the digital signal is converted to an analog signal, it is desirable to connect the converter 341 to its gauge 350 through a circuit capable of driving the gauge, and for smoothing the step output of the converter 341 thus driving the connected gauge smoothly from one reading to another. One embodiment of such a circuit is shown in the remainder of FIG. 17. 
     The output of the converter 341 is connected to the negative terminal of an operational amplifier 342. The output of the amplifier 342 is connected to a transfer circuit 345. The transfer circuit 345 is connected to the positive terminal of an operational amplifier 343, whose negative terminal is grounded. The output voltage at the output terminal of the smoothing circuit 344 has a feed-back loop for amplifier 343, which includes a capacitor 346 and a diode 347 to protect the capacitor 346. A feed-back conductor 348 connects the output terminal 344 to the positive terminal of operational amplifier 342 through resistor 349. 
     Any difference in the output and the input voltage of the smoothing circuit will adjust the output of the amplifier 342, thereby adjusting the output of operational amplifier 343 in such a fashion that the output will represent the input after a suitable time constant. The operational amplifier 343, acting as an integrator, will smooth out the differences at a slewing rate which will depend on the size of capacitor 346, the resistor in the transfer circuit 345, and the resistor 349. 
     A kelly position circuit, such as shown in FIG. 6, controlled by switch 78 of driller&#39;s panel 8 is connected to the penetration rate device 157 such that when the kelly position circuit is in the up condition, the penetration rate gauge 75 controlled by device 157 is turned off. Thus there is no penetration reading when the kelly is up. 
     An hydraulically controlled release valve position circuit controlled by switch 84 is similarly connected to input device 154, such that when the hydraulically controlled release valve circuit is in the closed condition, the casing pressure gauge 63 controlled by device 154 is turned off. The hydraulically controlled release valve position circuit is also connected to output device 149 such that when the valve position circuit is in the closed condition, device 149 transmits a zero to output circuit 141. Thus when the hydraulically controlled release valve is closed, the choke position reading is zero indicating a fully closed choke. This arrangement allows the calculator to determine if the well is shut-in without having to read the condition of the hydraulically controlled release valve position circuit. 
     When the annular preventer is closed, there can be no flow in the flow line. Thus an annular preventer&#39;s position circuit controlled by switch 80 is connected to input device 157 such that when the preventer position circuit is in the closed condition, the flow rate gauge 76 controlled by device 176 is turned off. 
     The pressure in the oil well can be divided into two types, static and circulating pressures. Static pressure, also referred to as hydrostatic head, is that pressure due to the column of mud above the particular point of interest. A pressure gradient can be calculated, dependent on the density of the mud concerned, in psi per foot. Thus, to find the pressure at the bottom of the hole, the total depth of the hole is corrected for deviation to find the true vertical depth, and then multiplied by this gradient to give the static portion of bottom hole pressure in psi. 
     Circulating pressures are basically friction losses which must be overcome by the pump as it pumps mud through the various surface equipment down the drill string 15, through the bit 13, up the annulus 12, and through the choke 41, when the choke is in the circulation path. The programmable calculator of the invention is programmed to calculate the static and circulating pressure dependent on data input to represent the well and the geometry of the circulating system being simulated. 
     The geometry input data supplied, with reference to the circulation system in FIG. 1, includes: 
     1. Total well depth in feet; 
     2. True vertical depth in feet; 
     3. Depth of the fracture gradient in feet of the formation; 
     4. Minimum fracture gradient in pounds per gallon, specific gravity, or pounds per cubic foot, which if exceeded, will result in lost circulation of drilling mud into the formation; 
     5. Length of the first drill pipe size 15 of the drill string in the well from the kelly to section line B in feet; 
     6. The outside diameter of the first drill pipe size 15 of the drill string; 
     7. The inside diameter of the first drill pipe size 15 of the drill string; 
     8. The length of the second drill pipe size of the drill string such as drill collar 14 from section line B to section line C; 
     9. The outside diameter of the second drill pipe size 14 of the drill string; 
     10. The inside diameter of the second drill pipe size 14 of the drill string; 
     11. The length of casing 11 from the surface to section line A; 
     12. The inside diameter in inches of casing 11; 
     13. The length of the open hole 10 from the section line A to section line C; and, 
     14. The diameter of open hole 10. 
     The well input data for the well being simulated includes: 
     1. Initial mud density in specific gravity, pounds per gallon, or pounds per cu. ft.; 
     2. The plastic viscosity of the mud in centipoise; 
     3. The yield point of the mud in pounds per hundred square feet; 
     4. The diameter of the bit nozzles; 
     5. The pressure of the formation in pounds per gallon; specific gravity, or pounds per cubic foot; 
     6. The type of invading fluid, gas or liquid; 
     7. The penetration rate of the drill bit 13 in feet per hour; 
     8. The output of the mud pump and auxiliary pump in barrels per stroke; and, 
     9. The maximum pressure in psi the surface equipment will withstand before failure. 
     It should be understood that in the following equation, the terms used will be defined only after their first appearance. Each subsequent appearance of like terms refers to the same parameter earlier defined. 
     The standpipe pressure (SPP) is calculated as the sum of the pressures in the circulation system expressed by the equation: 
     
         SPP = P.sub.b + ε P.sub.a + ε P.sub.p +  P.sub.s + ε H.sub.a - ε H.sub.p +  CP               (1) 
    
     where: 
     P b  = circulating pressure loss across the bit; 
     εP a  = the sum of circulating pressure losses in the annulus; 
     εP p  = the sum of circulating pressure losses in the drill string; 
     P s  = circulating pressure losses in the surface equipment; 
     εH a  = the sum of hydrostatic head in the annulus; 
     εH p  = the sum of hydrostatic head in the drill string; and 
     CP = the casing pressure. 
     The well bore may be divided into three zones of the same geometry. The first is from the surface to the bottom of the casing at line A. The second zone is from the bottom casing at line A to the change of drill pipe size in the drill string shown at line B. The third zone is from line B to the bottom of the hole at line C. The volume capacity of the drill string and the annulus in each of these zones can be calculated from the geometry input data. 
     The drill string and annulus volumes of each zone can then be divided by the length of each zone to obtain a volume gradient. The volume gradient described can be used to determine the length of drill pipe or annulus a volume of fluid will occupy as the fluid is circulated through the system. The volume gradient is used in the determination of the static and circulating pressure drops for the various fluids in the drill string and annulus, to be described hereafter. 
     The circulating pressure loss across the bit (P b ) is calculated as follows: 
     
         P.sub.b = (ρ.sub.b Q.sup.2)/(6.82 A.sup.2 C.sup.2)     (2) 
    
     where: 
     ρ b  = density of the mud flowing through the nozzles in pounds per gallon 
     A = total bit nozzle area in square inches; 
     C = a jet bit constant, typically 0.95; and, 
     Q = flow rate of the mud in barrels per minute. 
     The fixed parameters of the equation are used to derive a bit flow constant (K b ) thus simplifying the equation to: 
     
         P.sub.b = K.sub.b ρ.sub. b &#39; Q.sup.2                   (3) 
    
     where ρ b  &#39; is the density of the mud flowing through the nozzles multiplied by the appropriate constant to convert it to a pressure gradient in psi per foot. 
     The circulating pressure loss in the annulus (P a ) fore each zone of the annulus is calculated by the following equation: 
     
         P.sub.a = (θ.sub.a (i)L.sub.a (i))/(282D.sub.a (i))  (4) 
    
     where: 
     θ a  (i) = equivalent shear stress of the mud in the i th  zone in lb./100 ft. 2  ; 
     L a  (i ) = length of the i.sup. th zone of the annulus; and, 
     D a  (i) = hydraulic diameter of the i th  zone in inches. 
     The equivalent shear stress (θ a  (i)) is calculated in accordance with the following equation: 
     
         θ.sub.a (i) = K(R.sub.a (i)).sup.n                   (5 ) 
    
     where: 
     K = the power law consistency factor for laminar flow; 
     R a  (i) = the equivalent Fann V.G. meter rotary speed; and 
     n = power law flow behavior index for laminar flow. 
     K is calculated in accordance with the equation: 
     
         K = (PV + YP)/(300).sup.n                                  (6) 
    
     where: 
     PV = the input plastic viscosity in cps.; and, 
     YP = the input yield point in lb./100 ft. 2 . 
     n is calculated in accordance with the equation: 
     
         n = 3.32 log.sub.10 ((2PV+YP)/(PV+YP)).                    (7) 
    
     r a  (i) is calculated in accordance with the equation: 
     
         R.sub.a (i) = (0.939 G.sub.a (i) V.sub.a (i))/D.sub.a (i)  (8) 
    
     where: 
     G a  (i) = a geometric factor for the i th  annulus zone; and, 
     V a  (i) - the velocity of the fluid in the i th  annulus zone in ft./min. D a  (i) is calculated in accordance with the equation: 
     
         D.sub.a (i) = DCH(i)-ODP(i)                                (9) 
    
     where: 
     DCH(i) = the diameter of the casing or hole diameter of the i th  zone; and, 
     ODP(i) = the outside diameter of the drill string in the i th  zone. 
     G a  (i) is calculated in accordance with the equation: ##EQU1## where a(i) = the shape factor for the i th  zone; and, 
     β =  Fann V.G. meter constant, typically 1.068. 
     a(i) is calculated in accordance with the equation: 
     
         a(i) = 1-(1-α.sup.x (i)).sup.1/x                     (11) 
    
     where: 
     α = the ratio of ODP(i)/DCH(i); and, 
     x = 0.37n.sup. -0 .14. 
     The flow in the annulus is assumed to be in laminar flow. The annular circulating pressure loss equations may be solved using a unity velocity. The resulting pressure may then be divided by the total length of the annulus and the mud density expressed as psi/ft. to give an annulus circulating pressure change at unity velocity per foot density. This constant can then be used to approximate the annulus circulating pressure loss over any desired length of annulus and for changed mud densities and flow rates by the equation: 
     
         P.sub.a (i)≈K.sub.a Q.sup.n L.sub.a (i)ρ&#39;a(i)  (12) 
    
     where: 
     K a  = annulus circulating pressure loss constant; 
     Q = the flow rate in barrels per minute; 
     La(i) = the length of the i th  annulus zone; and, 
     ρ&#39;a(i) = the density in psi/ft. of the fluid in the i th  annulus zone. 
     The circulating pressure loss in the drill string (P p ) for each drill pipe size string is calculated in accordance with the equation: 
     
         P.sub.p = (θ.sub.p (i)L.sub.p (i))/(282ID.sub. p (i)) (13) 
    
     where: 
     θ p  (i) = the equivalent shear stress of the fluid in the i th  pipe string in lb./100 ft. 2  ; 
     L p  (i) = the length of the i th  string of drill pipe; and, 
     ID p  (i) = the inside diameter of the i th  string of drill pipe. 
     The equivalent shear stress (θ p  (i)) is calculated in accordance with the equation: ##EQU2## where: R p  (i) = equivalent Fann V.G. meter rotary speed for the i th  string; 
     ρ  p  (i) = the fluid density in lb./gal. for the fluid in the i th  string of drill pipe; 
     G p  (i) = a geometrical factor for the i th  string of drill pipe; 
     V p  (i) = velocity in ft./min. of the fluid in the i th  string of the drill pipe; 
     b and c = constants for turbulent friction factors; and, 
     n = the power law flow behavior index for laminar flow. 
     n is calculated in accordance with equation 7 above. 
     k is calculated in accordance with equation 6 above. 
     b is calculated in accordance with the equation: 
     
         b = (1.75-log.sub.10 n)7.0                                 (15) 
    
     c is calculated in accordance with the equation: 
     
         c = (log.sub.10 n+3.93)/50.0                               (16) 
    
     R p  (i) is calculated in accordance with the equation: 
     
         R.sub.p (i) = (0.939G.sub.p (i)V.sub.p (i))/ID.sub.p (i)   (17) 
    
     where: 
     ID p  (i) = the inside diameter of the drill string in the i th  string. 
     G p  (i) is calculated in accordance with the equation: 
     
         G.sub.p (i) = ((2n+1)/3n)/(β.sup.2/n /nβ.sup.2) ((β.sup.2 -1)/(β.sup.2/n -1)))                                 (18) 
    
     where: 
     β = Fann V.G. meter constant, typically 1.068. 
     The flow of the mud in the drill pipe is assumed to be in turbulent flow. 
     As with the annulus circulating pressure loss, the drill string pressure loss can be calculated with a unity velocity and the initial mud density to find the drill string circulating pressure loss for each size drill pipe in the well. The pressure loss calculated is then divided by the length of the drill pipe and the inital density of the mud expressed as psi/ft. to give a drill string circulating pressure loss constant for each string of drill pipe in the well. 
     This drill string circulating pressure loss constant can then be used to approximate the pressure loss over any length of similar drill pipe for a given flow rate and mud density in accordance with the following equation: 
     
         P.sub.p (i)≈K.sub.p Q.sup.s L.sub.p (i)ρ&#39;.sub.p (i) (19) 
    
     where: 
     K p  =  the drill string circulating pressure loss constant; 
     Q = the flow rate; 
     s = power law flow behavior index for turbulent flow; 
     L p  (i) = the length of the i th  section of drill pipe; and, 
     ρ&#39;(i) = the density in psi/ft. of the fluid in the i th  section of the drill pipe. 
     s is calculated in accordance with the equation: 
     
         a = nb-2b+2                                                (20) 
    
     An exact determination of the pressure losses in the surface equipment would be very complex. However, the surface equipment pressure losses are a small percentage of the total pressure losses in the total circulation system. It has been found that a reasonable approximation can be made for the purposes of the simulation by the equation: 
     
         P.sub.s ≈1.02(εP.sub.a +εP.sub.p +P.sub.b) (21) 
    
     The casing pressure (CP) during (CP the choke is equal to the circulating pressure losses )| the  D and is a function of several parameters including the density of the fluid flowing through the choke, the relative opening in the choke, and the flow rate of fluid through the choke. It has been found that casing pressure, when fluid is being pumped through the choke, may be approximated for the purpose of the simulation by the equation: 
     
         CP≈ρ.sub.c &#39;(69√Q.sub.r /(dc+1)).sup.4  (22) 
    
     where: 
     ρ c  &#39; = the density of the fluid flowing through the choke in psi/ft.; 
     Q r  = an approximated flow rate of the fluid flowing through the choke; and, 
     dc = the choke setting in percent, where O is fully closed and 100 is fully opened. 
     The flow rate (Q r ) of the fluid through the choke will be a composite flow rate with a component due to the pump rate and a component due to the expansion of the invading fluid in the annulus. It has been found that for the purposes of the simulation, the flow rate through the choke can be approximated by the equation: 
     
         Q.sub.r ≈(Q/0.2) + 10√ εVol.sub.if  (23) 
    
     where: 
     Q = the flow rate of the mud due to the pump rate; 
     εVol if  = the total volume of invading fluid in the annulus; and, 
     i = a number in the range of about 2 to 10. 
     The value of i is chosen to fit the calculator of the invention and the electronics of the panels in order to give a good simulation of the flow rate desired. The preferred value of i is 4. 
     If the well is shut-in, the casing pressure is calculated in accordance with the equation: 
     
         CP = SBHP-εH.sub.a                                 (24) 
    
     where: 
     Sbhp = the shut-in bottom hole pressure and is the greater of the formation pressure (FP) or the sum of the static mud pressure in the drill string (εH p ). 
     In addition to the displays of panels 7 and 8, the bottom hole pressure and equivalent mud weights at the minimum fracture gradient depth may be displayed on an appropriate observer&#39;s panel. Such a display would enable an instructor to monitor the bottom hole condition, thus evaluating the effectiveness of the students+ actions. 
     The bottom hole pressure (BHP) during circulation is calculated in accordance with the equation: 
     
         BHP = CP + εH.sub.a + εP.sub.a             (25) 
    
     The equivalent mud weight (ρ e ) in pounds per gallon at the minimum fracture gradient depth (D e ) may be calculated in accordance with the equation: 
     
         ρ.sub.e = (CP + εH.sub.a +ΕP.sub.a).sub.O.sup.De )/ 0.052D.sub.e)                                             (26) 
    
     where: 
     (εH a  30 εP a )| O   D  = the circulating pressure losses in the drill string and the annulus summed from the surface to the minimum fracture gradient depth; and, 
     D e  = the depth of the minimum fracture gradient in feet. 
     It is well known that the volume of formation fluid which will invade the wellbore when the formation pressure exceeds the bottom hole pressure can be calculated by the Darcy equation with two of the parameters being the formation porosity and formation permeability. It has been found that the rate of penetration can be substituted as a variable related to porosity and permeability to produce a synthetic Darcy equation for calculating the bottom hole volume of invading fluid (Vol if ) for simulation purposes by the equation: 
     
         Vol.sub.if = RP (FP-BHP)10.sup..sup.-4                     (27) 
    
     where: 
     RP = the input rate of penetration. 
     In order for the wellbore to receive a kick, it is necessary for the formation pressure to exceed the bottom hole pressure at some point during the simulation. Thus, the input formation pressure must be higher than the calculated bottom hole pressure in order for the simulated well to receive a kick. The calculator is programmed to calculate a formation pressure higher than the bottom hole pressure, to be discussed later. 
     If the invading fluid is gas, it will be controlled by the gas law as the gas is circulated to the surface. The gas law is expressed by the equation: 
     
         P.sub.1 V.sub.1 /T.sub.1 Z.sub.1 = P.sub.2 V.sub.2 /T.sub.2 Z.sub.2 (28) 
    
     where: 
     P 1 ,P 2  = pressure at point 1 and 2; 
     T 1 ,T 2  = temperature at point 1 and 2; 
     Z 1 ,Z 2  = compressibility at point 1 and 2; and, 
     V 1 ,V 2  = volumes at point 1 and 2. 
     The gas equation can be used to determine the volume of the gas as it is circulated to the surface. A typical temperature gradient is used to determine the temperature of the gas in relation to its depth as the gas moves to the surface. The compressibility or Z factor is a function of T and P, and an expression can be developed to express the Z factor at any point in the well. 
     The pressure on the gas (P g ) at a given depth in the well may be calculated by the equation: 
     
         P.sub.g = CP+εP.sub.a |.sub.O.sup.D +εH.sub.a |.sub.O.sup.D                                    (29) 
    
     where: 
     CP = the casing pressure calculated by equation 24, as the gas cannot expand if the well is shut-in; 
     εP a  | O   D   = the sum of annulus pressure losses from the surface to the depth of the gas calculated in accordance with equation 12; and 
     εH a  | O   D   = the sum of the static pressure of the mud in the annulus from the surface to the depth of the gas. 
     The compressibility factor (Z) may be calculated in accordance with the equation: 
     
         Z = 1-1.57 × 10.sup..sup.-4 (P.sub.g) + 4.85 × 10.sup..sup.-8 (P.sub.g).sup.2  - 3.99 ×  10.sup..sup.-12 (P.sub.g).sup.3 + 1.11 × 10.sup..sup.-16 (P.sub.g).sup.4                   (30) 
    
     Because the density of gas is much less than that of the mud in the annulus, the gas will migrate up the hole faster than the mud is being circulated. Thus, for a given increment of time, a volume of gas (ΔM) will displace a like volume of mud above it, and float to the surface faster than the mud which originally surrounded the gas. To correct the mud flow for this phenomenon, it can be considered that the mud above the gas is migrating down the annulus in ΔM barrel increments as the gas is migrating up the annulus. It has been found that this volume for simulation purposes may be approximated in accordance with the following equation: 
     
         ΔM = n(ρ&#39;.sub.OM /6)                             (31) 
    
     where: 
     ΔM = the barrels of mud displaced; 
     n = power law flow behavior index for laminar flow calculated in accordance with equation 7; and, 
     ρ&#39; OM  = the density in psi/ft. of the old mud, or the mud immediately above the gas in the annulus. 
     In order to account for the flow of two different densities of mud in the drill string, and the two muds and two different kicks of invading fluids in the annulus, eight data registers are reserved in the digital calculator to represent the volumes of the different fluids as they move through the well. These registers, identified hereafter by the parameters they contain, are illustrated in FIG. 11 and are tabulated as follows: 
     
         REF. NO REGISTER  REPRESENTS                                              
______________________________________                                    
301     VP1       new mud in the drill string                             
302     VP2       old mud in the drill string                             
303     VA6       new mud in the bottom of the annulus                    
304     VA5       old mud below the invading fluid                        
305     VA4       invading fluid, kick 2                                  
306     VA3       old mud between the kicks                               
307     VA2       invading fluid, kick 1                                  
308     VA1       old mud above the invading fluid                        
______________________________________                                    
 
    
     The total volume of mud pumped is determined from the cumulative pump strokes shown on display 71 and the volume of each stroke of the pump. The cumulative pump strokes before the counter display 71 is reset by reset button 56 represents the old mud pumped. The cumulative pump strokes after the display 71 is reset represents the new mud pumped. 
     As old mud is pumped into the drill string, its volume is added to register VP2 until the volume of VP2 equals the volume capacity of the drill string. The volume of old mud pumped above the capacity of the drill string is then added to register VA1 until the volume of VA1 equals the volume of the annulus. This condition will exist until kick 1 occurs. 
     The volume of the invading fluid of kick 1 calculated in accordance with equation 27 will be moved to register VA2. Old mud pumped after the well receives kick 1 will move into register VA3. As kick 1 migrates up the annulus in ΔM1 increments faster than the mud in register VA1, a volume of mud equal to ΔM per iteration can be considered as moving from VA1 to VA3. If the well receives a second kick, the volume of kick 2, calculated in accordance with equation 27, is moved to register VA4. Old mud pumped after the well receives kick 2 moves into register VA5. 
     As with kick 1, kick 2 migrates up the annulus in ΔM2 increments faster than the mud in register VA3. This is reflected as a volume of mud equal to ΔM2 per iteration being moved from register VA3 to VA5. 
     When new mud is pumped into the well, it will move into register VP1. An equal volume of old mud will be displaced from VP2 to VA5. When the volume of new mud in register VP1 equals the volume capacity of the drill string, the added new mud will be added to VA6. When the volume of new mud added to VA6, or the volume of old mud in VA5, equals the volume capacity of the annulus, the circulation is complete. 
     It can be seen that the sum of the volumes in the VA registers cannot exceed the volume capacity of the annulus. Any surplus will represent fluid displaced from the well. 
     By comparing the volumes in each volume register illustrated in FIG. 11 with the geometric zones determined for the drill string and annulus, the length of drill string and annulus each volume occupies can be determined. The volumes of old mud and new mud will determine the depth of the invading fluid in VA4. If the well is not shut-in, and the invading fluid is gas, it will expand in accordance with the pressure at its depth. 
     The pressure of the invading fluid in VA4 can be determined by equation 29. The volume of the gas at that depth can be determined by the gas law of equation 28. The volumes in registers VA4 and VA3 can, likewise, be used to determine the depth of kick 1 in register VA2. As before, the equations 29 and 28 can be used to determine the pressure and volume of kick 1. The volume of kick 1 will then determine the volume of old mud in VA1. 
     It will now be understood that εVOL if  of equation 23 is VA2 + VA4. Equation 23 thus becomes: 
     
         Q.sub.r ≈(Q/0.2) + 10√VA2+VA4               (32) 
    
     the volumes of the registers of FIG. 11 can be calculated in accordance with the following equations to simulate the fluid flow through the well: 
     
         VP1 - BNM                                                  (33) 
    
     where: 
     BNM = barrels of new mud pumped; and where the value of VP1 is greater than or equal to zero, and less than or equal to the total volume of the drill string (εV p ). 
     
         VP2 = εV.sub.p -VP1                                (34) 
    
     where the value VP2 is not less than zero. 
     
         VA6 = BNM-VP1                                              (35) 
    
     where: 
     BNM = barrels of new mud pumped; and, the value of VA6 is greater than or equal to zero, and less than or equal to the total volume of the annulus (εV a ). 
     
         VA3 = (BOM + VP1) + ΔM1-ΔM2                    (36) 
    
     where the expression (BOM+BP1) is greater than or equal to zero, and less than or equal to (εV a ). 
     
         VA5 = (BOM-VA3+ΔM2)                                  (37) 
    
     where the value of VA5 is greater than or equal to zero, and less than or equal to (εV a ). 
     
         VA1 = εV.sub.a -(VA2+VA3+VA4+VA5+VA6)              (38) 
    
     where, if the invading fluid is gas, the volumes of VA2 and VA3 are the volumes of gas expanded as explained above in accordance with equations 28 and 29. 
     The pump rate and the barrels of mud pumped per stroke can then be used to determine Q in barrels per minute. The densities of the old mud and new mud, and the length of each volume in the VP and VA register is known. Thus, using equations 12 and 19, the circulating pressure losses in the drill string and annulus can be calculated. Typical density values for salt water or gas can be used with equation 19 to determine the circulating pressure losses of the invading fluid in VA2 and VA4. Also using the densities and lengths of the muds and invading fluid, the static pressures can, likewise, be determined. 
     The circulating pressure bit loss is calculated in accordance with equation 3. Pressure losses in the surface equipment is calculated in accordance with equation 21. The flow rate through the choke is calculated in accordance with equation 32. The casing pressure is calculated in accordance with the equation 22, if there is circulation through the choke, or equation 24, if the well is shut-in. All of the various pressures are now known in order to calculate the standpipe pressure in accordance with equation 1. 
     A set of numerical codes is established to represent a failure in some part of the circulation system. These degree of difficulty codes (DOD) can include: 
     0 = no failure; 
     1 = plugged nozzle; 
     2 = washout in drill pipe; 
     3 = pump swab cut out; and 
     -1 = any one of the above, plus allowing the calculator to determine the formation pressure and the type of invading fluid. 
     At an appropriate time in the calculation, the DOD code is checked and, dependent on its value, the parameters of the appropriate equation is changed to simulate the failure desired. For instance, for a DOD code of 1, the constant K b  of equation 3 would be changed to show the decrease in the total bit nozzle area A of equation 2. For a DOD code of 2, the constant K b  will be changed to zero. For a DOD code of 3, the flow rate Q of equations 12, 19 and 33 will be greatly reduced, requiring the operator to change to the auxiliary pump. 
     If the DOD code is -1, the formaton pressure and type of invading fluid is determined from a random number, generated from a time-dependent value which is not likely to repeat itself from simulation to simulation. The preferred time-dependent number is the standpipe pressure (SPP) calculated from the current control setting and input data. The random number (N) is calculated in accordance with the equation: 
     
         N = √SPP+2 -INT(√SPP+2)                      (39) 
    
     where: 
     INT indicates that only the digits to the left of the decimal, or the integer value of the expression, is used in the equation. For example, if the standpipe pressure equals 958.6 psi, then √SPP+2 = 30.9935, and INT(√SPP+2) = 30. 
     Thus, the random number generated in accordance with equation 39 is 0.9935. It can thus be seen that the random number N will always be equal to or greater than zero, and less than one. 
     The formation pressure calculated in response to the random number is calculated in accordance with the equation: 
     
         FP = TD(TVD/TD) (π&#39;+0.04+N/20)                          (40) 
    
     where: 
     TVD = the input initial total vertical depth; 
     TD = the input initial total depth; and, 
     π&#39; = the initial density of the mud expressed in psi/ft, the ratio (TVD/TD) having been previously calculated and stored for use as a hole deviation correction factor for the hydrostatic head calculation. 
     Equation 39 is expressed as taking the square root of the time dependent variable. However, the variable could be raised to any fractional power to give a random number less than one, and greater than zero. Also, the constants 0.04 and 20 in equation 40 can be substituted by other constants which, when used with the random number N, will result in a reasonable increase in formation pressure above the bottom hole hydrostatic pressure of the mud in the well. 
     If the DOD code is -1, the random number N is also used to generate a new random DOD code. Since N is greater than 0 and less than 1, it can be multiplied by 4, and the digit to the left of the decimal will always be a digit greater than 0, but less than 4. Thus, the calculator generated DOD code equation is: 
     
         DOD = INT (4N)                                             (41) 
    
     failure of the circulation system is simulated in accordance with the DOD code when: ##EQU3## 
     This insures that the failure will occur while the kick is in the lower portion of the annulus. 
     PROGRAMMABLE CALCULATOR INSTRUCTIONS 
     The programmable calculator 130 in the invention may be programmed to perform the foregoing calculations to determine the pressures and volumes desired. Programming is done with the instruction set compatible with the particular calculator being used. The instruction set for use with the preferred calculator is set out in the manual &#34;600 Series Reference Manual with Programming&#34; published by Wang Laboratories, Inc., in 1972, which may be used by one skilled in the art to program the calculator of the disclosed embodiment. 
     The calculator programming is divided into two programs which include: a data input and constant initialization program labeled BOSS-O and illustrated in FIG. 8; and a main simulation program labeled BOSS-M and illustrated in FIG. 9, which includes a pressure subroutine illustrated in FIG. 10 for calculating the various pressures during the execution of the BOSS-M program. 
     The BOSS-O routine of FIG. 8 is started at start instruction 200. The previously listed geometry data is input by the operator at block 201, and listed by the calculator at block 202. The calculator then stops at block 203 to allow the operator to verify the data input at block 204. If the data is wrong, the operator returns to block 201 and corrects the incorrect data. 
     If the data is correct, the calculator then divides the well at block 205 into zones between the surface and line A, line B and line C of FIG. 1. At block 206, the volumes of the various well zones are determined as heretofore described. Also, at 206, these zones are described as gradients in barrels per foot for use in correlating the volumes of the VP and VA registers to drill string and annulus lengths. 
     The calculator then stops at 207 to indicate to the operator that it is ready to accept the well data. Well data is entered at 209 by the operator, and printed at 210 by the calculator for verification. The calculator stops at 211 to allow the operator to verify the data at 212. If there is an error, the operator returns to point 208 to correct the error. When the data is correct, the operator instructs the calculator to continue execution. 
     In block 213 the mud density, referred to as mud weight, is examined to determine the units used. Density unit conventions vary from region to region. Therefore, if the value is equal to or greater than 4, but less than 40, the units are assumed to be in lbs./gal. If the value is equal to or greater than 40, the units are assumed to be in lb./cu.ft. If the value is less than 4, the units are assumed to be in specific gravity. Once the units are determined, the density is multiplied by the proper constant to convert the density units to psi per ft. 
     In block 214 the input data is used to determine the various laminar and turbulent flow constants for use in determining the circulating drill pipe and annulus pressure losses. The constants are calculated in accordance with equations 5-11, and equations 14-18. V a  (i) of equation 8, and V p  (i) of equation 14 are assumed to be at a value which will give a pressure loss in per unit velocity. 
     The circulation pressure loss in the annulus is calculated at block 215 in accordance with equation 4. The determined pressure loss is then divided at block 216 by the length of the annulus and the initial mud density to give the constant K a  for later use in equation 12. 
     Likewise, the circulation pressure loss in the drill string is calculated at block 217 in accordance with equation 13. This determined pressure loss is then divided at block 218 with the length of the drill string and the initial mud density to give the constant K p  for later use in equation 19. 
     The total bit nozzle area is used at block 219 to calculate the bit flow constant K b  for later use in equation 3 for calculating the circulating pressure loss across the bit. 
     The constants developed and the input data needed in the BOSS-M routine are then relocated at block 220 into suitable data registers where they can later be accessed as called for. The BOSS-O routine ends at block 221. 
     It can be seen that the constants developed in the BOSS-O routine will greatly simplify the later pressure calculations. 
     The BOSS-M simulation routine of FIG. 9 starts at block 222. The mud weight reading set on digital device 64 is read at block 226 by the calculator output means 131 of FIG. 7 by placing the address for device 152 on address line 135, as discussed earlier. At block 227, the values of volumes in the VP and VA registers of FIG. 11 are initialized and the mud weight is converted to psi/ft. as discussed in connection with block 213 of FIG. 8. 
     At block 229, the volume and gradient registers are reinitialized in response to a determination which indicates that a circulation out of the well kick is complete. This determination is made by comparing the volume of mud in registers VA5 and VA6 to the volume of the annulus. 
     The start of the circulation simulation loop starts at point 232. 
     Each time the calculator program passes point 232, the value of a parameter indicating the number of loops before a kick is initiated (loops-to-kick) is decreased by one. The initial value of loops-to-kick is input by the operator prior to the execution of the BOSS-M program. 
     A comparison is made at 234 to see if the value of loops-to-kick is greater than or equal to zero. A value of loops-to-kick greater than or equal to zero indicates a normal circulation is taking place. If the comparison of 234 is true, the pressure subroutine is called at block 235, the pressures are printed at block 236, and a new loop is started at 232. The printing operation at 236 provides a permanent record of the simulation to be used, for example, as a record of the student&#39;s training. It is preferable to print only after a selected number of loops in order to keep the record manageable. 
     A value of loops-to-kick less than zero at 234 indicates that a well kick is being or is about to be initiated. The false branch of 234 is the start of the well kick loop. It will be seen during the discussion of FIG. 10 that the cumulative pump strokes display will have been read during the pressure subroutine. A present value of cumulative pump strokes on this loop less than the cumulative pump strokes on the last loop indicates that the stroke counter 71 has been reset. This determination is made at 237. If the strokes have been reset, the calculator at 238 reads the mud weight control 64. The mud weight counter is read only once during each kick circulation because of the limited capacity of the calculator. More checks per circulation could be made if the calculator could account for more than two mud densities at the same time. 
     If the strokes display has not been reset, barrels of old mud pumped is calculated at block 239. However, if the strokes display has been reset, barrels of new mud pumped is calculated at block 239. The relationship of equation 42 is compared at 240 to determine if the degree of difficulty failure is to occur during this loop. If the comparison is true, the appropriate constant is adjusted at 241 to simulate the failure called for by the value of the degree of difficulty code. It will be noted that during the first kick loop, the random number has not yet been generated; and, there is no machine-generated DOD code in the case where the DOD code is to be selected by the calculator program. However, block 241 will be executed only after several kick loops have been executed and the random number N has been generated. 
     The bottom hole pressure is compared to the formation pressure at block 242; and if the formation pressure is higher, the invading fluid volume will be added to the volume value stored in either VA2 or VA4 in accordance with equation 27. The initial value of formation pressure is set equal to or lower than the value of bottom hole pressure in order that the well kick not be initiated until after the first well kick loop. 
     A comparison is made at 243 to determine if the value of loops-to-kicks equals -1. If the comparison is true, it indicates that this loop is the first loop of a kick. The value of rate of penetration is increased by a set amount, such as multiplying the rate of penetration by √3, to indicate a drilling break. This higher value is output to device 157 for display on gauge 75 of driller&#39;s panel 8 to indicate the initiation of a well kick. 
     The gas law values of pressure, temperature, and compressibility are determined at 245 for the bottom of the hole conditions for later use in correcting the volume of gas as the gas moves to the surface. 
     The random number N is generated at block 246, and is used to calculate the formation pressure at block 251. After the formation pressure is calculated in the first well kick loop, the volume accounting equations are executed at block 252. The volume accounting equations are equations 33-38 wherein the volumes of mud and invading fluid are determined for registers VP1, VP2 and VA1 to VA6. 
     The volume of VA5 and VA6 is compared to the volume of the annulus at 253 to determine if a complete circulation has been made. If the comparison is true, the program returns to point 228 and executes the reinitialization of block 229 as discussed above. If a circulation has not been completed, each volume in the VP and VA registers is converted to lengths in accordance with the volume gradients calculated at block 206 of FIG. 8. If the lengths of the various volumes indicate that gas is present at the surface, the gas sound is turned on. If the fluid at the surface is not gas, the gas sound is turned off. 
     The pressure subroutine is called at block 255 for calculating and displaying various pressures. Selected pressures are printed at 256 to continue the permanent record of the simulation. 
     After the first well kick loop, the comparisons of 243 will be false, and the program will branch to block 247. The calculator output means 131 will output at 247 the pit volume change to device 160 for display on digital display 72 of choke panel 7. It will be noted that the pit volume change is actually the change calculated in the previous loop. 
     At block 248 the state of the preventer switch 80 and the percent opening of the choke is read. A comparison is made at 249 to determine if the preventor is closed, and if the choke is closed. If the comparison of 249 is true, the well is shut-in and the invading fluid, if gas, cannot expand. In that case, the program branches to the execution of block 252. 
     If the comparison of 249 is false, and the invading fluid is gas, block 250 is executed. By knowing the length of mud volumes in register VA6 and VA5, the depth of the gas in VA4 can be determined. The pressure on the gas is then calculated in accordance with equation 29. The gas law of equation 28 is then used to determine the new volume of the gas which is then stored in VA4. This new volume is then converted to a length. The lengths of the volumes in registers VA6, VA5, VA4 and VA3 can then be used to locate the depth of the gas volume in register VA2. The pressure on the gas volume in VA2 is calculated in accordance with equation 29. Equation 28 is then used to calculate the new volume of the gas, which is then stored in VA2. After the expanded volumes of the gas are calculated and stored, the program continues to block 252. 
     The BOSS-M routine continues in the loop until stopped by the operator, or until an error condition occurs. 
     The pressure subroutine, called at blocks 235 and 255, starts at 270 of FIG. 10. It can be seen that the subroutine need actually only appear once if the logic flow is from the true side of 234 to block 255. 
     The various data registers used by the calculator for the pressure calculations are initialized at block 271. Since there is a delay before a change in pump rate is felt at the casing pressure, this delay is simulated by calculating the casing pressure based on some previous reading of pump rate. The delay desired can be controlled by which previous reading is used in the calculation. Block 272 advances the previous reading stored to make room in the proper data register for the new reading. The pump rate and pump number is read at block 273. 
     The static mud pressures in the annulus and the drill string are calculated at 274 by multiplying the mud densities in psi/ft. of the respective mud in the VP and VA registers by the length of each mud volume as calculated in block 254 of FIG. 9. The static pressures may also be corrected for hole deviation by multiplying the resultant pressures by TVD/TD. 
     The circulating pressure losses are calculated at 275 in accordance with equations 3, 12, 19 and 21 and summed. There is a delay between the time a pressure appears on the casing until it is reflected to the standpipe pressure. To simulate this delay, an old casing pressure calculated in a previous loop is added at 176 to the summed value of block 275 to give the standpipe pressure. 
     The choke and preventer settings are read at 277 and a comparison is made at 278 to determine if the well is shut-in. If the comparison at 278 is true, the program branches to 279. If the invading fluid is gas, it is determined at 279 how far up the annulus the gas will migrate. Each kick will displace Δ M1 and Δ M2 barrels of mud respectively for each loop as the gas rises faster than the mud. Since the gas in a shut-in well cannot expand, its pressure will remain the same as it rises, thereby increasing the casing pressure with each incremental lift of the gas. The incremental increase in casing pressure is calculated by converting the length of each volume of mud displaced, and multiplying those lengths by the density of the mud in psi/ft. 
     Further, at 279, the casing pressure is calculated in accordance with equation 24, and, if gas, the pressure due to the migration of unexpanded gas is added. 
     If the comparison of 278 is false, the pressure loss across the choke, which is also the casing pressure, is calculated in accordance with equation 22. The flow rate Q r  is also output by the calculator to input device 156 for display on gauge 76. As previously explained, the display will be inhibited if the annulus preventer circuit is in the closed condition. 
     The casing and the standpipe pressure are output at 281 by the calculator to device 154 and 155 for display by gauges 61, 63 and 83 of panels 7 and 8. The casing pressure and standpipe pressure are shifted in the data registers at 282 such that the oldest casing pressure is dropped from storage and the newest casing pressure is added to storage. This shifting or rotating of pressure values places the values in the proper registers in order that the oldest casing pressure may be used in the standpipe calculation of block 276 in the next pressure calculation. 
     Equivalent mud weight is calculated at 283 in accordance with equation 26. If the comparison at 284 of equivalent mud weight to the minimum fracture gradient is true, the calculator initiates the error 1 signal indicating lost circulation. The routine then stops at 286 and will restart at 287 by operation of the restart button 57 of panel 7. 
     If the comparison at 284 is false, the bottom hole pressure is calculated at 288 in accordance with equation 25. If an observer&#39;s panel is used, the bottom hole pressure and equivalent mud weight are output at 289 by the calculator to devices 158 and 159 for display. 
     A comparison is made at 290 to determine if either the standpipe pressure or the casing pressure exceeds the maximum allowable surface equipment pressure. If the comparison at 290 is true, then an error 2 signal is generated by the calculator at 291, and the calculator stops executing at 292, and is restarted at 293 by the operation of start button 57. 
     If the comparison at 290 is false, a comparison is made to determine if the kick volumes in VA2 and VA4 are greater than a maximum volume which if exceeded, makes control of the well impossible. If the coparison at 294 is true, the calculator generates an error 3 signal which indicates a blowout. The calculator stops execution at 296, and is restarted at 297 by operation of start button 57. 
     If the comparison at 294 is false, the next step in the main routine after the calling of the pressure subroutine is executed. 
     The flow diagram of FIGS. 8, 9 and 10 are intended to be illustrative only. Alternate ways of achieving the same results will occur to those skilled in the art after study of FIGS. 8, 9 and 10. 
     A program listing, similar to the program illustrated in FIG. 8, is appended as TABLE I. 
     A program listing, similar to the program illustrated in FIG. 9 and containing a pressure routine similar to the pressure illustrated in FIG. 10, is appended as TABLE II. 
     Other types of circulating problems and systems can be simulated by the invention by changing the program to be executed by the calculator and by changing the parameters which the manual controls represent. For instance, control 66 and switch 67 can represent the rate and direction of movement of the drill string during a trip. In this situation, a kick may occur if the hole is not kept full of mud as the drill pipe is removed; or, if the pipe is pulled too fast, the swabbing effect of the pipe moving out of the hole may reduce the bottom hole pressure sufficiently to allow formation fluid to invade the well bore. These effects may be included in the pressure calculation routine with suitable pressure equations, and the volume gradients may be changed in each loop to indicate the enlarging of the annulus and decreasing of the drill string volumes as the drill string is withdrawn. 
     Treating systems may also be simulated in which various chemicals are pumped down the well and into the formation. In this case, control 66 could simulate a second pump rate control and one of the gauges, such as gauge 61, could simulate manifold pressure. Such a simulation would be useful in training well treating personnel in various well treating techniques. ##SPC1## ##SPC2## 
     The present invention may thus be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The presently disclosed embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.