! [File: ~mech403/public_html/optdes/Twobar_english.f90] Revised 9/12/00 ! SAMPLE OPTDES APPLICATION SUBROUTINES, F90 version ! construction complete, buckling not checked SUBROUTINE anapre (model_Name) !==================================================================== !...subroutine ANAPRE ! preprocessing routine, called only once to set title, etc !-------------------------------------------------------------------- IMPLICIT NONE CHARACTER(17), intent (out) :: model_Name ! create a "named" common to access input or output, if needed ! common / My_In / density, modulus ! name "12345678901234567" of the model (17 char) model_Name = "Two Bar Truss" ! open the post processing output, if needed OPEN (unit = 10, file = "post_process.out", status = "unknown") ! call any code needed to start the process END SUBROUTINE anapre SUBROUTINE anafun !==================================================================== !...subroutine ANAFUN, called for every trial vector (each iteration) ! sample analysis routine for a two bar truss !-------------------------------------------------------------------- IMPLICIT NONE DOUBLE PRECISION :: height, diameter, width, enclosed ! for My_Out DOUBLE PRECISION :: thickness, specific_wt, modulus, & yield_stress, axial_load, length, area, i_over_a, & weight, axial_stress, euler_buckling, axial_defl, & vert_defl, code_defl, l_by_r, short, aisc_stress, & aisc_safe, aisc_buckling, ratio, johnson, buckling, & FS_yield, FS_buckle, FS_defl ! set problem constants DOUBLE PRECISION, PARAMETER :: pi = 3.141593d0, pi_sq = pi * pi, & g = 9.8066d0 DOUBLE PRECISION, PARAMETER :: euler_safe = 23.d0 / 12.d0 ! create a "named" common to access input or output, if needed COMMON / My_Out / height, diameter, width, enclosed !...input scalar analysis variables (AV) values for this iteration ! description '123456789012345' CALL avdsca (height, 'height, in ') CALL avdsca (width, 'width, in ') CALL avdsca (diameter, 'diameter, in ') ! mean diameter CALL avdsca (thickness, 'thickness, in ') CALL avdsca (specific_wt, 'spec_wt, pci ') CALL avdsca (modulus, 'modulus, ksi ') CALL avdsca (yield_stress, 'yield, ksi ') CALL avdsca (axial_load, 'load, kips ') !...compute scalar analysis function (AF) values !...intermediate constants, length, area, radius of gyration length = sqrt ( (width / 2.d0) **2 + height **2) area = pi * diameter * thickness i_over_a = (thickness **2 + diameter **2) / 8.d0 !...compute functions, mass, axial stress, Euler stress, ! mechanical axial_deflection weight = specific_wt * area * length axial_stress = axial_load * length / (2.d0 * height * area) euler_buckling = pi_sq * modulus * i_over_a / length **2 euler_buckling = euler_buckling / euler_safe axial_defl = axial_load * length / (modulus * area) vert_defl = axial_defl * (0.5d0 * length **2 / height **2) code_defl = length / 360.d0 ! building code !... other buckling rules l_by_r = sqrt (length **2 / i_over_a) short = pi * sqrt (2.d0 * modulus / yield_stress) aisc_stress = (1.d0 - 0.5d0 * (l_by_r / short) **2) * yield_stress aisc_safe = 5.d0/3.d0 + (l_by_r / short) * & (3.d0 - (l_by_r / short) **2) / 8.d0 aisc_buckling = aisc_stress / aisc_safe ratio = yield_stress * length **2 / & (4.d0 * pi_sq * modulus * i_over_a) johnson = yield_stress * (1.d0 - ratio) !... keep lowest buckling rule buckling = euler_buckling ! if ( aisc_buckling < buckling ) buckling = aisc_buckling ! if ( johnson < buckling ) buckling = johnson !...compute Safety Factors FS_yield = yield_stress / axial_stress FS_buckle = buckling / axial_stress FS_defl = code_defl / axial_defl !...output scalar analysis functions (AF) values [to X-windows] ! description '123456789012345' (15 char) CALL afdsca (FS_yield, 'Safety: yield ') CALL afdsca (FS_buckle, 'Safety: buckle ') CALL afdsca (FS_defl, 'Safety: deflect') CALL afdsca (weight, 'weight, lb ') CALL afdsca (axial_stress, 'X-Stress, ksi') CALL afdsca (buckling, 'Buckling, ksi') CALL afdsca (vert_defl, 'Deflection, in ') END SUBROUTINE anafun SUBROUTINE anapos !==================================================================== !...subroutine ANAPOS, only called if "Postprocess" button is hit. ! postprocessing routine, if needed !-------------------------------------------------------------------- IMPLICIT NONE DOUBLE PRECISION :: height, diameter, width, enclosed ! for My_Out INTEGER, SAVE :: count = 0 ! save counts between calls ! create a "named" common to access input or output, if needed COMMON / My_Out / height, diameter, width, enclosed ! carry out post-processing count = count + 1 enclosed = height * width ! bounding box ! save to my post-processing file WRITE (10, * ) ' ' WRITE (10, * ) 'Design number = ', count WRITE (10, * ) 'height, width = ', height, width WRITE (10, * ) 'enclosed area = ', enclosed END SUBROUTINE anapos ! check syntax with f95 compiler: f95 -c Twobar_english.f90 ! create executable file named "try": ! f95 -o try Twobar_english.o /usr/site/OptdesX/lib/supportF.o -lnsl -lsocket ! then execute: OptdesX try