home *** CD-ROM | disk | FTP | other *** search
-
- -- This procedure solves a few physics problems involving
- -- time, distance, vecocity and acceleration. All units are
- -- in the MKS system of units. Note that all "put" calls
- -- on physical quantities are to be printed as the value followed
- -- by the unit.
- --
- -- make available types for physical units
- with PHYSICAL_UNITS_BASIC ; use PHYSICAL_UNITS_BASIC ;
- with PHYSICAL_UNITS_MECHANICAL ; use PHYSICAL_UNITS_MECHANICAL ;
- with PHYSICAL_UNITS_ELECTRICAL ; use PHYSICAL_UNITS_ELECTRICAL ;
- with PHYSICAL_UNITS_OTHER ; use PHYSICAL_UNITS_OTHER ;
-
- -- make available operations on MKS types
- with MKS_PHYSICS_MECHANICAL ; use MKS_PHYSICS_MECHANICAL ;
- with MKS_PHYSICS_ELECTRICAL ; use MKS_PHYSICS_ELECTRICAL ;
-
- -- make available units conversion constants
- with PHYSICAL_CONVERSION_CONSTANT ; use PHYSICAL_CONVERSION_CONSTANT ;
-
- -- make PUT available for physical units types
- with PHYSICAL_UNITS_OUTPUT_BASIC ; use PHYSICAL_UNITS_OUTPUT_BASIC ;
- with PHYSICAL_UNITS_OUTPUT_MECHANICAL ; use PHYSICAL_UNITS_OUTPUT_MECHANICAL ;
- with PHYSICAL_UNITS_OUTPUT_ELECTRICAL ; use PHYSICAL_UNITS_OUTPUT_ELECTRICAL ;
-
- --
- with TEXT_IO ; use TEXT_IO ;
-
- procedure Z000018 is
-
- -- define acceleration due to gravity
- G : ACCELERATION_MKS := DIMENSION ( 9.80665 ) ;
- FALL : DISTANCE_METER ;
- FALL_TIME : TIME_SECOND ;
- V_FINAL : VELOCITY_METER_PER_SECOND ;
- begin
- PUT ( " Test printout and value of acceleration, " ) ;
- PUT ( G ) ;
- PUT_LINE ( " = G " ) ;
-
- -- How far will Ball_1 fall in 1.5 second in earths gravity ?
- FALL := 0.5 * G * TIME_SECOND' ( DIMENSION( 1.5 )) ** 2 ;
- PUT ( FALL ) ;
- NEW_LINE ;
-
- -- Cross check that the time for the ball to fall is 1.5 seconds.
- FALL_TIME := SQRT ( 2.0 * FALL / G ) ;
- PUT ( FALL_TIME ) ;
- NEW_LINE ;
-
- -- Now determine the final velocity if the ball falls another 0.2 meter
- -- Method : square root of initial velocity squared plus twice
- -- the acceleration times the distance
- V_FINAL := SQRT (( G * FALL_TIME ) ** 2 + 2.0 * G * FALL) ;
- PUT ( V_FINAL ) ;
- NEW_LINE ;
- end Z000018 ;
-