|
- SUBROUTINE DEALLOCATE_ARRAYS()
- USE VARIABLES
- implicit none
- !===========================================================================
- ! RAMLINE MINOR LOSSES INPUT
- !===========================================================================
- DEALLOCATE (MINORS1,MINORDIAMETER_RAMLINE,AREAMINOR_RAMLINE &
- ,LF_RAMLINE,CV_RAMLINE,NOTE_RAMLINE,RAMS%minlosspa,RAMS%minloss)
- !===========================================================================
- ! RAMLINE PIPNING LOSSES INPUT
- !===========================================================================
- DEALLOCATE (PIPINGS_RAMLINE,DIAM_RAMLINE_INCH, &
- AREA_RAMLINE,LENGT_RAMLINE,ROUGHNESS_RAMLINE,RELROUGH_RAMLINE &
- ,RAMS%Re_ramline,RAMS%fric,RAMS%fricloss)
- !===========================================================================
- ! ANNULAR MINOR LOSSES INPUT
- !===========================================================================
- DEALLOCATE (MINORS_ANNULAR,MINORDIAMETER_ANNULARLINE,AREAMINOR_ANNULARLINE &
- ,LF_ANNULARLINE,CV_ANNULARLINE,NOTE_ANNULARLINE,minlosspa_ANNULAR,minloss_ANNULAR)
- !===========================================================================
- ! ANNULAR PIPNING LOSSES INPUT
- !===========================================================================
- DEALLOCATE (PIPINGS_ANNULAR,DIAM_ANNULARLINE_INCH,AREA_ANNULARLINE, &
- LENGT_ANNULARLINE,ROUGHNESS_ANNULARLINE,RELROUGH_ANNULARLINE &
- ,Re_ANNULARline,fricANNULAR,friclossANNULAR)
- !===========================================================================
- ! AIR PUMP LOSSES INPUT
- !===========================================================================
- DEALLOCATE (PIPINGS_AIRPUMP,DIAM_AIR_INCH, &
- Re_air,AREA_AIR,LENGT_AIR,ROUGHNESS_AIRPLINE,REL_ROUGHAIR, &
- fric_air,fricloss_air)
- !================================================================
- DEALLOCATE (MINORS_AIRPUMP,MINORDIAM_AIR_INCH, &
- MINORAREA_AIR,LF_AIR,CV_AIR,NOTE_AIR &
- ,minlosspa_air,minloss_air)
-
- !===========================================================================
- ! DELAY ARRAYS
- !===========================================================================
- call Pannular_regDelay%Empty()
-
-
-
- END
-
-
-
-
-
-
-
-
-
-
-
- SUBROUTINE LOSS_INPUTS()
- USE VARIABLES
- implicit none
- INTEGER I
-
- !===========================================================================
- ! RAMLINE MINOR LOSSES INPUT
- !===========================================================================
- NO_MINORSRAMLINE=34
-
- ALLOCATE (MINORS1(NO_MINORSRAMLINE,4))
-
- ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
- MINORS1(1,1:4)= (/2., 2., 0., 0./) !Acc.tee
- MINORS1(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS1(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS1(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS1(5,1:4)= (/2., 0.9, 0., 0./) !tee
- MINORS1(6,1:4)= (/2., 2., 0., 0./) !tee
- MINORS1(7,1:4)= (/2., 0., 105., 0./) !valve
- MINORS1(8,1:4)= (/2., 0.9, 0., 0./) !tee
- MINORS1(9,1:4)= (/2., 0., 105., 0./) !valve
- MINORS1(10,1:4)= (/2., 0.42, 0., 0./) !elbow
- MINORS1(11,1:4)= (/2., 0.42, 0., 0./) !elbow
- MINORS1(12,1:4)= (/2., 0.8, 0., 0./) !unionA
- MINORS1(13,1:4)= (/2., 0.8, 0., 0./) !unionA
- MINORS1(14,1:4)= (/2., 1.5, 0., 0./) !elbow
- MINORS1(15,1:4)= (/2., 0., 425., 0./) !valve
- MINORS1(16,1:4)= (/2., 2., 0., 0./) !tee
- MINORS1(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR
- MINORS1(18,1:4)= (/1., 2., 0., 0./) !tee
- MINORS1(19,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS1(20,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS1(21,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS1(22,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS1(23,1:4)= (/1., 0., 105., 0./) !valve
- MINORS1(24,1:4)= (/1., 0.9, 0., 0./) !tee
- MINORS1(25,1:4)= (/1., 0., 0., 0.5/) !FT
- MINORS1(26,1:4)= (/1., 0., 0., 3.4/) !filter
- MINORS1(27,1:4)= (/1., 0., 105., 0./) !valve
- MINORS1(28,1:4)= (/1., 0.9, 0., 0./) !tee
- MINORS1(29,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS1(30,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS1(31,1:4)= (/1., 0., 9.2, 0./) !valve
- MINORS1(32,1:4)= (/1., 0.8, 0., 0./) !unionA
- MINORS1(33,1:4)= (/1., 0.8, 0., 0./) !unionA
- MINORS1(34,1:4)= (/0.75, 0.35, 0., 0./) !contraction
-
-
- ALLOCATE (MINORDIAMETER_RAMLINE(NO_MINORSRAMLINE),AREAMINOR_RAMLINE(NO_MINORSRAMLINE),LF_RAMLINE(NO_MINORSRAMLINE),CV_RAMLINE(NO_MINORSRAMLINE) &
- ,NOTE_RAMLINE(NO_MINORSRAMLINE),RAMS%minlosspa(6,NO_MINORSRAMLINE),RAMS%minloss(6,NO_MINORSRAMLINE))
-
-
-
- DO I=1,NO_MINORSRAMLINE
- MINORDIAMETER_RAMLINE(I)=MINORS1(I,1)
- LF_RAMLINE(I)=MINORS1(I,2)
- CV_RAMLINE(I)=MINORS1(I,3)
- NOTE_RAMLINE(I)=MINORS1(I,4)
-
-
- AREAMINOR_RAMLINE(I)=PI*(MINORDIAMETER_RAMLINE(I)*0.0254)**2/4. !D(in), AREA(m)
- ENDDO
-
-
- !===========================================================================
- ! RAMLINE PIPNING LOSSES INPUT
- !===========================================================================
- NO_PIPINGSRAMLINE=15
-
- ALLOCATE (PIPINGS_RAMLINE(NO_PIPINGSRAMLINE,3))
-
- ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
- PIPINGS_RAMLINE(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance
- PIPINGS_RAMLINE(2,1:3)= (/2., 730., 0.03/) !Acc.end.horizontal
- PIPINGS_RAMLINE(3,1:3)= (/2., 2000., 0.03/) !Acc.end.vertical
- PIPINGS_RAMLINE(4,1:3)= (/2., 6000., 0.05/) !Hyd.hose
- PIPINGS_RAMLINE(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1
- PIPINGS_RAMLINE(6,1:3)= (/2., 210., 0.03/) !Add.from.bend
- PIPINGS_RAMLINE(7,1:3)= (/1., 780., 0.03/) !Corner.horizontal1
- PIPINGS_RAMLINE(8,1:3)= (/1., 780., 0.03/) !Corner.horizontal2
- PIPINGS_RAMLINE(9,1:3)= (/1., 750., 0.03/) !Extra.length.back
- PIPINGS_RAMLINE(10,1:3)= (/1., 800., 0.03/) !Corner.horizontal3
- PIPINGS_RAMLINE(11,1:3)= (/1., 1650., 0.03/) !Corner.vertical2
- PIPINGS_RAMLINE(12,1:3)= (/1., 340., 0.03/) !12.Valves.horizontal
- PIPINGS_RAMLINE(13,1:3)= (/1., 1650., 0.03/) !Valves.vertical
- PIPINGS_RAMLINE(14,1:3)= (/1., 31000., 10./) !Hyd.hose
- PIPINGS_RAMLINE(15,1:3)= (/1., 526., 0.03/) !Add.from.bend
-
-
-
- ALLOCATE (DIAM_RAMLINE_INCH(NO_PIPINGSRAMLINE), &
- AREA_RAMLINE(NO_PIPINGSRAMLINE),LENGT_RAMLINE(NO_PIPINGSRAMLINE),ROUGHNESS_RAMLINE(NO_PIPINGSRAMLINE),RELROUGH_RAMLINE(NO_PIPINGSRAMLINE) &
- ,RAMS%Re_ramline(6,NO_PIPINGSRAMLINE),RAMS%fric(6,NO_PIPINGSRAMLINE),RAMS%fricloss(6,NO_PIPINGSRAMLINE))
-
- DO I=1,NO_PIPINGSRAMLINE
- DIAM_RAMLINE_INCH(I)=PIPINGS_RAMLINE(I,1)
- LENGT_RAMLINE(I)=PIPINGS_RAMLINE(I,2)
- ROUGHNESS_RAMLINE(I)=PIPINGS_RAMLINE(I,3)
-
-
-
- AREA_RAMLINE(I)=PI*(DIAM_RAMLINE_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
- RELROUGH_RAMLINE(I)=ROUGHNESS_RAMLINE(I)/(DIAM_RAMLINE_INCH(I)*25.4) !e/D
- !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
- LENGT_RAMLINE(I)=LENGT_RAMLINE(I)*.001 ! (m)
- ENDDO
-
-
-
- !===========================================================================
- ! ANNULAR PREVENTER MINOR LOSSES INPUT
- !===========================================================================
- NO_MinorsAnnularLine=29
-
- ALLOCATE (MINORS_ANNULAR(NO_MinorsAnnularLine,4))
-
- ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
- MINORS_ANNULAR(1,1:4)= (/2., 2., 0., 0./) !Acc.tee
- MINORS_ANNULAR(2,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS_ANNULAR(3,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS_ANNULAR(4,1:4)= (/2., 0.9, 0., 0./) !Avg.acc.tee
- MINORS_ANNULAR(5,1:4)= (/2., 0.9, 0., 0./) !tee
- MINORS_ANNULAR(6,1:4)= (/2., 2., 0., 0./) !tee
- MINORS_ANNULAR(7,1:4)= (/2., 0., 105., 0./) !valve
- MINORS_ANNULAR(8,1:4)= (/2., 0.9, 0., 0./) !tee
- MINORS_ANNULAR(9,1:4)= (/2., 0., 105., 0./) !valve
- MINORS_ANNULAR(10,1:4)= (/2., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(11,1:4)= (/2., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(12,1:4)= (/2., 0.8, 0., 0./) !unionA
- MINORS_ANNULAR(13,1:4)= (/2., 0.8, 0., 0./) !unionA
- MINORS_ANNULAR(14,1:4)= (/2., 1.5, 0., 0./) !elbow
- MINORS_ANNULAR(15,1:4)= (/2., 0., 425., 0./) !valve
- MINORS_ANNULAR(16,1:4)= (/2., 2., 0., 0./) !tee
- MINORS_ANNULAR(17,1:4)= (/0.75, 0., 1.5, 0./) !REGULATOR
- MINORS_ANNULAR(18,1:4)= (/1., 2., 0., 0./) !tee
- MINORS_ANNULAR(19,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS_ANNULAR(20,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(21,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(22,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS_ANNULAR(23,1:4)= (/1., 0., 3.2, 0./) !valve
- MINORS_ANNULAR(24,1:4)= (/1., 2., 0., 0./) !tee
- MINORS_ANNULAR(25,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS_ANNULAR(26,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(27,1:4)= (/1., 0.42, 0., 0./) !elbow
- MINORS_ANNULAR(28,1:4)= (/1., 1.5, 0., 0./) !elbow
- MINORS_ANNULAR(29,1:4)= (/1., 0., 3.2, 0./) !valve
-
-
-
- ALLOCATE (MINORDIAMETER_ANNULARLINE(NO_MinorsAnnularLine),AREAMINOR_ANNULARLINE(NO_MinorsAnnularLine),LF_ANNULARLINE(NO_MinorsAnnularLine) &
- ,CV_ANNULARLINE(NO_MinorsAnnularLine),NOTE_ANNULARLINE(NO_MinorsAnnularLine),minlosspa_ANNULAR(NO_MinorsAnnularLine),minloss_ANNULAR(NO_MinorsAnnularLine))
-
-
-
- DO I=1,NO_MinorsAnnularLine
- MINORDIAMETER_ANNULARLINE(I)=MINORS_ANNULAR(I,1)
- LF_ANNULARLINE(I)=MINORS_ANNULAR(I,2)
- CV_ANNULARLINE(I)=MINORS_ANNULAR(I,3)
- NOTE_ANNULARLINE(I)=MINORS_ANNULAR(I,4)
-
- AREAMINOR_ANNULARLINE(I)=PI*(MINORDIAMETER_ANNULARLINE(I)*0.0254)**2/4. !D(in), AREA(m)
- ENDDO
-
-
- !===========================================================================
- ! ANNULAR PREVENTER PIPNING LOSSES INPUT
- !===========================================================================
- NO_PipingsAnnularLine=10
-
- ALLOCATE (PIPINGS_ANNULAR(NO_PipingsAnnularLine,3))
-
- ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
- PIPINGS_ANNULAR(1,1:3)= (/2., 1035., 0.03/) !Avg.acc.distance
- PIPINGS_ANNULAR(2,1:3)= (/2., 730., 0.03/) !Acc.endhorizontal
- PIPINGS_ANNULAR(3,1:3)= (/2., 2000., 0.03/) !Acc.endvertical
- PIPINGS_ANNULAR(4,1:3)= (/2., 6000., 0.03/) !Hyd.hose
- PIPINGS_ANNULAR(5,1:3)= (/2., 2370., 0.03/) !Corner.vertical1
- PIPINGS_ANNULAR(6,1:3)= (/2., 210., 0.03/) !Add.frombend
- PIPINGS_ANNULAR(7,1:3)= (/2., 1000., 0.03/) !manifold
- PIPINGS_ANNULAR(8,1:3)= (/1., 46000., 0.03/) !pipe
- PIPINGS_ANNULAR(9,1:3)= (/2., 1000., 0.03/) !manifold
- PIPINGS_ANNULAR(10,1:3)= (/1., 46000., 0.03/) !pipe
-
-
-
-
- ALLOCATE (DIAM_ANNULARLINE_INCH(NO_PipingsAnnularLine),AREA_ANNULARLINE(NO_PipingsAnnularLine),LENGT_ANNULARLINE(NO_PipingsAnnularLine) &
- ,ROUGHNESS_ANNULARLINE(NO_PipingsAnnularLine),RELROUGH_ANNULARLINE(NO_PipingsAnnularLine) &
- ,Re_ANNULARline(NO_PipingsAnnularLine),fricANNULAR(NO_PipingsAnnularLine),friclossANNULAR(NO_PipingsAnnularLine))
-
-
- DO I=1,NO_PipingsAnnularLine
- DIAM_ANNULARLINE_INCH(I)=PIPINGS_ANNULAR(I,1)
- LENGT_ANNULARLINE(I)=PIPINGS_ANNULAR(I,2)
- ROUGHNESS_ANNULARLINE(I)=PIPINGS_ANNULAR(I,3)
-
-
- AREA_ANNULARLINE(I)=PI*(DIAM_ANNULARLINE_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
- RELROUGH_ANNULARLINE(I)=ROUGHNESS_ANNULARLINE(I)/(DIAM_ANNULARLINE_INCH(I)*25.4)
- !DIAM_ANNULARLINE_MM(I)=DIAM_ANNULARLINE_MM(I)*.001 ! (m)
- LENGT_ANNULARLINE(I)=LENGT_ANNULARLINE(I)*.001 ! (m)
- ENDDO
-
-
- !===========================================================================
- ! AIR PUMP LOSSES INPUT
- !===========================================================================
- NO_PIPINGS_AIRPLINE=1
-
- ALLOCATE (PIPINGS_AIRPUMP(NO_PIPINGS_AIRPLINE,3))
-
- ! ID(INCH) L(MM) ROUGHNESS(MM)=e DESCRIPTION
- PIPINGS_AIRPUMP(1,1:3)= (/2., 10000., 0.03/) !Avg.acc.distance
-
-
-
-
- ALLOCATE (DIAM_AIR_INCH(NO_PIPINGS_AIRPLINE),Re_air(NO_PIPINGS_AIRPLINE),AREA_AIR(NO_PIPINGS_AIRPLINE), &
- LENGT_AIR(NO_PIPINGS_AIRPLINE),ROUGHNESS_AIRPLINE(NO_PIPINGS_AIRPLINE),REL_ROUGHAIR(NO_PIPINGS_AIRPLINE), &
- fric_air(NO_PIPINGS_AIRPLINE),fricloss_air(NO_PIPINGS_AIRPLINE))
-
-
-
- DO I=1,NO_PIPINGS_AIRPLINE
- DIAM_AIR_INCH(I)=PIPINGS_AIRPUMP(I,1)
- LENGT_AIR(I)=PIPINGS_AIRPUMP(I,2)
- ROUGHNESS_AIRPLINE(I)=PIPINGS_AIRPUMP(I,3)
-
-
- AREA_AIR(I)=PI*(DIAM_AIR_INCH(I)*0.0254)**2/4 !D(in), AREA(m)
- REL_ROUGHAIR(I)=ROUGHNESS_AIRPLINE(I)/(DIAM_AIR_INCH(I)*25.4)
- !DIAM_RAMLINE_MM(I)=DIAM_RAMLINE_MM(I)*.001 ! (m)
- LENGT_AIR(I)=LENGT_AIR(I)*.001 ! (m)
- ENDDO
-
-
-
- !================================================================
- NO_MINORS_AIRPLINE=6
-
- ALLOCATE (MINORS_AIRPUMP(NO_MINORS_AIRPLINE,4))
-
- ! ID(INCH) LF CV NOTE(BAR) DESCRIPTION
- MINORS_AIRPUMP(1,1:4)= (/2., 10., 0., 0./) !Acc.tee
- MINORS_AIRPUMP(2,1:4)= (/2., 11., 0., 0./) !elbow
- MINORS_AIRPUMP(3,1:4)= (/1., 0., 0., 3.4/) !filter
- MINORS_AIRPUMP(4,1:4)= (/2., 0., 105., 0./) !valve
- MINORS_AIRPUMP(5,1:4)= (/1., 0., 9.2, 0./) !valve
- MINORS_AIRPUMP(6,1:4)= (/2., 6.4, 0., 0./) !unionA
-
-
-
- ALLOCATE (MINORDIAM_AIR_INCH(NO_MINORS_AIRPLINE),MINORAREA_AIR(NO_MINORS_AIRPLINE), &
- LF_AIR(NO_MINORS_AIRPLINE),CV_AIR(NO_MINORS_AIRPLINE),NOTE_AIR(NO_MINORS_AIRPLINE) &
- ,minlosspa_air(NO_MINORS_AIRPLINE),minloss_air(NO_MINORS_AIRPLINE))
-
-
-
- DO I=1,NO_MINORS_AIRPLINE
- MINORDIAM_AIR_INCH(I)=MINORS_AIRPUMP(I,1)
- LF_AIR(I)=MINORS_AIRPUMP(I,2)
- CV_AIR(I)=MINORS_AIRPUMP(I,3)
- NOTE_AIR(I)=MINORS_AIRPUMP(I,4)
-
-
- MINORAREA_AIR(I)=PI*(MINORDIAM_AIR_INCH(I)*0.0254)**2/4. !D(in), AREA(m)
- ENDDO
-
-
-
- END
-
- SUBROUTINE pumps_charge_bottle()
- USE VARIABLES
- USE CAccumulatorVariables
- USE CBopStackVariables
- USE CBopControlPanelVariables
- USE CEquipmentsConstants
- USE CSimulationVariables
- implicit none
-
- !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
- !write(*,*) 'pumps_charge_bottle'
-
- if(ByePassValve == -1.0) then
- ByPassOld= -1.0
- elseif(ByePassValve == 1.0) then
- ByPassOld= 1.0
- endif
-
-
- !=====================================================================
- ! ACCUMULATOR
- !=====for a 10 gal bottle,precharge=1000psig curve BOSCH-isotherm=====
- !for charging bottles by the pump
- !((((((((IN OUTER LOOP))))))
- ! ba1=1003; ba2=.03375; ba3=4.014; ba4=.2458;
- if (airp_switch==0) deltav_air=0
- fvr=fvr+deltav_air+deltav_elecp
-
- pacc_before=p_acc
- p_acc=b1*exp(b2*fvr/nobottles)+b3*exp(b4*fvr/nobottles) ! adiabatic(psig)<<<< 8=no. of bottles
-
- !=====================================================================
-
-
- if(ByPassOld == 1.0) then
-
- if (pram_reg<PRAMS_REGSET) then
- !pram_reg=pram_reg+(p_acc-pacc_before)
- PressureDifference= (p_acc-pacc_before)
- else
- !pram_reg=PRAMS_REGSET
- PressureDifference= PRAMS_REGSET - pram_reg
- endif
-
-
- !old=pram_reg
- !difference= new-old
- if (ABS(PressureDifference) > BaseDifferenceP) then
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
-
- if (pram_reg<PRAMS_REGSET) then
- pram_reg=pram_reg+(p_acc-pacc_before)
- else
- pram_reg=PRAMS_REGSET
- endif
-
- endif
-
-
-
-
-
- else !if(ByPassOld == -1.0) then
-
-
- !old=pram_reg
- !new=p_acc- MAXVAL(RAM%loss_before)
- !difference= new-old
- PressureDifference= p_acc- MAXVAL(RAM%loss_before) - pram_reg
- if (ABS(PressureDifference) > BaseDifferenceP) then
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
- pram_reg= p_acc- MAXVAL(RAM%loss_before)
- endif
-
- endif
-
-
- !Pannular_reg= min(p_acc,Pannular_regset)
-
-
- end
-
-
- SUBROUTINE airpump_code()
- USE VARIABLES
- use CSounds
- implicit none
- INTEGER I
-
-
-
- QAIR_PUMP=Qiter+.1 !(gpm) maximum flow for the start
- diffp_air=-10
- losses_air=10
-
- !===================================================================
- ! AIR OPERATED PUMP
- !=================for air consumption at 8 bar======================
- do while (diffp_air<0)
- QAIR_PUMP=QAIR_PUMP-.1
- ! Qup=QAIR_PUMP;
- ! bba1 =31.8; bba2 =-725.7 ; bba3 =4154;
- p_airp=bba1*QAIR_PUMP**2+bba2*QAIR_PUMP+bba3 !(psig)
- kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-5/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
-
-
- diffp_air=p_airp+kinetic_air-p_acc
-
- end do !returns Qup
-
-
- do while (abs((diffp_air-losses_air)/diffp_air)>tol_air) !finding correct QAIR_pump for 1 timecounter_ram
-
- if (diffp_air-losses_air>0) then
- QAIR_PUMP=QAIR_PUMP+.01
- else
- QAIR_PUMP=QAIR_PUMP-.01
- endif
-
- !===================================================================
- ! AIR OPERATED PUMP
- ! Maximator - Model: GX (35)
- !=================for air consumption at 8 bar======================
-
- p_airp=bba1*QAIR_PUMP**2+bba2*QAIR_PUMP+bba3 !(psig)
- kinetic_air=sg*wdens*(QAIR_PUMP*6.30902e-005/((1/4.)*pi*(2*0.254e-1)**2))**2/(2*6895) !(psi)
-
- diffp_air=p_airp+kinetic_air-p_acc
-
-
- !===========================LOSSES====================================
- do i=1,NO_PIPINGS_AIRPLINE
- Re_air(i)=QAIR_PUMP*6.30902e-005*DIAM_AIR_INCH(I)*0.0254/(area_air(i)*nu)
- enddo
-
- do i=1,NO_PIPINGS_AIRPLINE
- if (Re_air(i)<Re_cr) then
- fric_air(i)=64/Re_air(i)
- else
- fric_air(i)=1/(-1.8*log10((rel_roughair(i)/3.7)**1.11+6.9/Re_air(i)))**2
- endif
-
- fricloss_air(i)=((fric_air(i)*(wdens*sg*lengt_air(i)*(QAIR_PUMP*6.30902e-005/area_air(i))**2))/(2*DIAM_AIR_INCH(I)*0.0254))/6895
-
- enddo
-
-
-
-
- pipe_loss1air=sum(fricloss_air) !loss before regulator(psi)
-
- do i=1,NO_MINORS_AIRPLINE
- if (LF_air(i)/=0) then
- minlosspa_air(i)=LF_air(i)*wdens*sg*(QAIR_PUMP*6.30902e-005/MINORAREA_AIR(i))**2/2 !(Pa)
- minloss_air(i)=minlosspa_air(i)/6895 !(psi)
- elseif (CV_air(i)/=0) then
- minlosspa_air(i)=1000*sg*((11.7*QAIR_PUMP*6.30902e-005*3600)/(CV_air(i)))**2 !(pa)
- minloss_air(i)=minlosspa_air(i)/6895 !(psi)
- else
- minlosspa_air(i)=NOTE_air(i)*1e5 !(pa)
- minloss_air(i)=minlosspa_air(i)/6895 !(psi)
- endif
- enddo
-
-
- minor_loss1air=sum(minloss_air) !loss before regulator(psi)
-
- static_loss1air=0
-
- losses_air=pipe_loss1air+minor_loss1air+static_loss1air !(psi)
- !=========================================================================
-
-
-
- end do !returns correct QAIR_PUMP for 1 counter
-
- counter_airp=counter_airp+1
- Qiter=QAIR_PUMP
-
- Cumulative_AirVolume= Cumulative_AirVolume + ((QAIR_PUMP * DeltaT_BOP / 60.0 ) / (6.71*0.004329004) ) ! =strokes
- !write(*,*) 'Cumulative_AirVolume=' , Cumulative_AirVolume
-
- if ( Cumulative_AirVolume > 1.0 ) then
- SoundKoomeyAirPump= 120.0
- Cumulative_AirVolume= Cumulative_AirVolume - 1.0
- else
- SoundKoomeyAirPump= 0.0
- endif
-
-
- !SoundKoomeyAirPump= int ( (QAIR_PUMP/ (6.71*0.004329004)) ) ! 6.71: Volume per stroke (in^3) , 0.004329004: in^3 to gal
- ! 2.0 : two air pumps 60:seconds
- !write(*,*) 'sedaaaa=' ,(QAIR_PUMP/ (6.71*0.004329004)) *DeltaT_BOP/(60.0*2.0)
- call SetSoundKoomeyAirPump(SoundKoomeyAirPump)
-
-
- deltav_air=QAIR_PUMP*DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
-
- !write(*,*) 'QAIR_PUMP=' , QAIR_PUMP
-
-
- !((((((((IN OUTER LOOP))))))
- !fvr_air=fvr_air+deltav_air !=fvr_after (galon) for next timecounter_ram
-
-
- !========================================================
-
- !WRITE(50,50) QAIR_PUMP,p_airp, &
- !p_acc,diffp_air,losses_air,deltav_air
- 50 FORMAT(6(f15.5))
-
-
- end
-
-
- SUBROUTINE bop_code(ramtype,H_RAMBOP,RNUMBER)
-
- USE VARIABLES
- USE CAccumulatorVariables
- USE CBopControlPanelVariables
- USE CEquipmentsConstants
- USE CSimulationVariables
- USE TD_GeneralData
- use CUnityOutputs
- implicit none
- integer ramtype, I
- real H_RAMBOP
- INTEGER RNUMBER
-
- !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
-
- !====================================================
- ! BOP back pressure IN PRESENCE OF DP
- !====================================================
- if (RAM(RNUMBER)%bop_type==2) then
- RAM(RNUMBER)%checkp= RAM(RNUMBER)%p_bop
- if ( RAM(RNUMBER)%vdis_tot<va) then
- RAM(RNUMBER)%p_bop=pa
- elseif (va<= RAM(RNUMBER)%vdis_tot .and. RAM(RNUMBER)%vdis_tot<=vb) then
- RAM(RNUMBER)%p_bop=pa+pb*(( RAM(RNUMBER)%vdis_tot-va)/(vb-va))
- else
- RAM(RNUMBER)%p_bop=pa
- endif
-
- if ( RAM(RNUMBER)%checkp/=pa .and. RAM(RNUMBER)%p_bop==pa) then
- RAM(RNUMBER)%Q=RAM(RNUMBER)%Qzero
- else
- RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
- endif
-
- endif
-
- !====================================================
- ! BOP back pressure without DP
- !====================================================
- if (RAM(RNUMBER)%bop_type==3) then
- RAM(RNUMBER)%p_bop=pa
- ! Q=flow
- endif
-
-
-
- RAM(RNUMBER)%clock=0
- !======================Losses============================
- RAM(RNUMBER)%loss_after=0 !initial value
- RAM(RNUMBER)%diffp_ram=1000 !initial value
- RAM(RNUMBER)%loss_before=0
-
- !Q=0.0055; %initial flow rate (m^3/s)
-
- RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
-
-
- do while (abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)/ RAM(RNUMBER)%diffp_ram>RAM(RNUMBER)%tol)
- if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit
- ! while abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)>10
- RAM(RNUMBER)%clock= RAM(RNUMBER)%clock+1
-
- if ( RAM(RNUMBER)%clock>20) then
- ! tclock=clock
- RAM(RNUMBER)%tol= RAM(RNUMBER)%TOLZERO+(floor( RAM(RNUMBER)%clock/10)-1)*.001
- endif
- ! if (clock==1) continue
-
- if ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after> RAM(RNUMBER)%diffp_ram) then
- RAM(RNUMBER)%Q=RAM(RNUMBER)%Q-.1
- elseif ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after<= RAM(RNUMBER)%diffp_ram) then
- RAM(RNUMBER)%Q=RAM(RNUMBER)%Q+.01
-
- endif
-
- !====================Before Regulator=========================
- !pipe_loss1=3.2; % should be replaced by formula
- do i=1,NO_PIPINGSRAMLINE
- RAMS%Re_ramline(RNUMBER,i)=RAM(RNUMBER)%Q*6.30902e-5*DIAM_RAMLINE_INCH(i)*0.0254/(AREA_RAMLINE(i)*nu)
-
- enddo
-
-
-
- do i=1,NO_PIPINGSRAMLINE
- if ( RAMS%Re_ramline(RNUMBER,i)<Re_cr) then
- RAMS%fric(RNUMBER,i)=64/ RAMS%Re_ramline(RNUMBER,i)
- else
-
- RAMS%fric(RNUMBER,i)=1/(-1.8*log10((RELROUGH_RAMLINE(i)/3.7)**1.11+6.9/ RAMS%Re_ramline(RNUMBER,i)))**2
- endif
-
- RAMS%fricloss(RNUMBER,i)=(( RAMS%fric(RNUMBER,i)*(wdens*sg*LENGT_RAMLINE(i)*(RAM(RNUMBER)%Q*6.30902e-5/AREA_RAMLINE(i))**2))/(2*DIAM_RAMLINE_INCH(i)*0.0254))/6895
-
- enddo
-
-
-
-
- RAM(RNUMBER)%pipe_loss1=sum( RAMS%fricloss(RNUMBER,1:6)) !loss before regulator(psi)
-
- ! Q*6.30902e-5 for (gpm) to (m^3/sec)
- do i=1,NO_MINORSRAMLINE
- if (LF_RAMLINE(i)/=0) then
- RAMS%minlosspa(RNUMBER,i)=LF_RAMLINE(i)*wdens*sg*(RAM(RNUMBER)%Q*6.30902e-5/AREAMINOR_RAMLINE(i))**2/2 !(Pa)
- RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
- elseif (CV_RAMLINE(i)/=0) then
- RAMS%minlosspa(RNUMBER,i)=1000*sg*((11.7*RAM(RNUMBER)%Q*6.30902e-5*3600)/(CV_RAMLINE(i)))**2 !(pa)
- RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
- else
- RAMS%minlosspa(RNUMBER,i)=NOTE_RAMLINE(i)*1e5 !(pa)
- RAMS%minloss(RNUMBER,i)= RAMS%minlosspa(RNUMBER,i)/6895 !(psi)
- endif
- enddo
-
- RAMS%minloss(RNUMBER,17)= 5.*RAM(RNUMBER)%Q ! <==== regulator loss (psig)
-
- RAM(RNUMBER)%minor_loss1=sum( RAMS%minloss(RNUMBER,1:16)) !loss before regulator(psi)
-
- RAM(RNUMBER)%static_loss1=0
-
- RAM(RNUMBER)%kinetic_loss1=sg*wdens*(RAM(RNUMBER)%Q*6.30902e-5/((1/4.)*pi*(.72*0.254e-1)**2))**2/(2*6895) !(psi)
- !.72 for regulator diameter)
-
- RAM(RNUMBER)%loss_before= RAM(RNUMBER)%pipe_loss1+ RAM(RNUMBER)%minor_loss1+ RAM(RNUMBER)%static_loss1+ RAM(RNUMBER)%kinetic_loss1 !(psi)
- !===================after Regulator======================
- ! all in (psi)
- RAM(RNUMBER)%pipe_loss2=sum( RAMS%fricloss(RNUMBER,7:NO_PIPINGSRAMLINE)) !7=after regulator<<<<<<<
- RAM(RNUMBER)%minor_loss2=sum( RAMS%minloss(RNUMBER,17:NO_MINORSRAMLINE)) !17=after regulator<<<<<<<
-
- RAM(RNUMBER)%deltah=H_RAMBOP-H_REGRAM
- ! RAM(RNUMBER)%static_loss2pa= RAM(RNUMBER)%deltah*sg*wdens*gravity; %(pa)
- RAM(RNUMBER)%static_loss2= RAM(RNUMBER)%deltah*sg*wdens*gravity/6895 !(psi)
- RAM(RNUMBER)%kinetic_loss2=0
-
- RAM(RNUMBER)%loss_after= RAM(RNUMBER)%pipe_loss2+ RAM(RNUMBER)%minor_loss2+ RAM(RNUMBER)%static_loss2 !(psi)
- !=======================================================
-
- if(ByePassValve == -1.0) then
- ByPassOld= -1.0
- elseif(ByePassValve == 1.0) then
- ByPassOld= 1.0
- endif
- ! write(*,*) 'ByPassOld=', ByPassOld
-
-
- !==========================p_regulator======================
- if (PRAMS_REGSET<p_acc- RAM(RNUMBER)%loss_before) then
-
- if(ByPassOld == 1.0) then
- !old=pram_reg
- !new=PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
- !difference= new-old
- PressureDifference= PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) - pram_reg
- if (ABS(PressureDifference) > BaseDifferenceP) then
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
- pram_reg= PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
- endif
- !pram_reg=PRAMS_REGSET- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
- else !(ByPassOld == -1.0)
- !old=pram_reg
- !new=p_acc- RAM(RNUMBER)%loss_before
- !difference= new-old
- PressureDifference= p_acc- RAM(RNUMBER)%loss_before - pram_reg
- if (ABS(PressureDifference) > BaseDifferenceP) then
- pram_reg= pram_reg + (PressureDifference/PressureDifferenceSteps) ! PressureDifferenceSteps = 20.
- else
- pram_reg= p_acc- RAM(RNUMBER)%loss_before
- endif
-
- endif
- !pram_reg=p_acc- RAM(RNUMBER)%loss_before
-
- else
- pram_reg=p_acc- RAM(RNUMBER)%loss_before- sum(RAMS%minloss(2:6,17)) ! 2:6 = RNUMBER
- endif
- !===========================================================
-
-
- !====================Flow Rate calculation==================
- RAM(RNUMBER)%diffp_ram=pram_reg+RAMS%minloss(RNUMBER,17)- RAM(RNUMBER)%p_bop
- !write(*,*) 'Q calculation'
-
-
- end do ! returns correct Q for one timecounter_ram
- !write(*,*)'RAM(RNUMBER)%Q= ' , RAM(RNUMBER)%Q
-
- !write(*,*) 'UpperRamsLeakMalf , Bottles_Charged_MalfActive=' , UpperRamsLeakMalf , Bottles_Charged_MalfActive
- if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) then
- RAM(RNUMBER)%Q= 5.0 ! gpm
- !write(*,*) 'malffffffffff'
- endif
-
- RAM(RNUMBER)%flow=RAM(RNUMBER)%Q
-
-
-
- !====================p_accumulator for next iterate==================
- ! deltav=Q*1*1000; %delta_t=1sec (lit)
- ! fvr=fvr-deltav; %=fvr_after (lit)
- ! p_acc=0.001178*fvr^3+0.02019*fvr^2+16.1*fvr+2379; %(psia)
- ! vdis_bottles=fvr_tot-fvr; %from the start***needed for p_bop calculating (lit)
-
- !========for a 10 gal bottle,precharge=1000psig curve BOSCH======
- RAM(RNUMBER)%deltav_bottles=RAM(RNUMBER)%Q*DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
- fvr=fvr- RAM(RNUMBER)%deltav_bottles !=fvr_after (galon)
- ! b1=993.7; b2=0.164; b3=5.492; b4=0.9796;
- RAM(RNUMBER)%p_acccheck=p_acc
- p_acc=b1*exp(b2*fvr/nobottles)+b3*exp(b4*fvr/nobottles) !(psig)<<<< 8=no. of bottles
- !formula is derived for fvr (galon)
- !vdis_bottles=fvr_tot-fvr
- RAM(RNUMBER)%vdis_bottles= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%deltav_bottles
-
- NoActiveRmas=6.-real(Annular_closed+ShearBop_closed+PipeRam1_closed+PipeRam2_closed+ChokeLine_closed+KillLine_closed)
-
- RAM(RNUMBER)%vdis_elecp= RAM(RNUMBER)%vdis_elecp+(deltav_elecp/NoActiveRmas) !overal discharged
- RAM(RNUMBER)%fvr_air= RAM(RNUMBER)%fvr_air+(deltav_air/NoActiveRmas) !=fvr_after (galon) for next timecounter_ram
- !write(*,*) 'deltav_air , NoActiveRmas' , deltav_air , NoActiveRmas
-
- RAM(RNUMBER)%vdis_tot= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%fvr_air+ RAM(RNUMBER)%vdis_elecp !overal
- ! write(*,*) RAM(RNUMBER)%vdis_tot, vdis_bottles, RAM(RNUMBER)%fvr_air, vdis_elecp !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- if (ramtype==1) then !for shear ram
- if (ShearRamIsClosing) then
- IDshearBop=(2.*(NeededVolumeShearRams- RAM(RNUMBER)%vdis_tot)*231./AbopShearRam) +ShearIsNotAllowed*ODDrillpipe_inShearRam
- !write(*,*) 'stop now' !, IDshearBop, NeededVolumeShearRams, RAM(RNUMBER)%vdis_tot, AbopShearRam
- endif
-
- if (ShearRamIsOpening) then
- IDshearBop=IDshearBopBase-2.*(NeededVolumeShearRams- RAM(RNUMBER)%vdis_tot)*231./AbopShearRam
- endif
-
-
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumeShearRams) then
-
- ShearBop_closed=1
- !ShearBop_closed_withPossibility= ShearBop_closed * TD_BOPConnectionPossibility(3)
-
- pram_reg=pram_reg+RAMS%minloss(RNUMBER,17)
- p_acc= RAM(RNUMBER)%p_acccheck
-
- if (ShearRamIsClosing) then
- IDshearBop=0. + ShearIsNotAllowed*ODDrillpipe_inShearRam
- MiddleRamsCloseLED = LedOn
- MiddleRamsCloseLEDMine = LedOn
- MiddleRamsOpenLED = LedOff
- MiddleRamsOpenLEDMine = LedOff
- if (TD_BOPConnectionPossibility(3) == 1 .and. ShearIsNotAllowed==0) then
- CALL CloseMiddleRams
- ShearBop_Situation_forTD= 1 ! closed - for TD code
- endif
- endif
-
- if (ShearRamIsOpening) then
- IDshearBop=IDshearBopBase
- MiddleRamsOpenLED = LedOn
- MiddleRamsOpenLEDMine = LedOn
- MiddleRamsCloseLED = LedOff
- MiddleRamsCloseLEDMine = LedOff
- CALL OpenMiddleRams
- ShearBop_Situation_forTD= 0 ! open - for TD code
- endif
-
- endif
-
- IDshearBopFinal= IDshearBop ! for output data
-
- endif
-
- if (ramtype==2) then !for pipe ram1
- if (PipeRam1IsClosing) then
- IDPipeRam1=(2.*(NeededVolumePipeRams1- RAM(RNUMBER)%vdis_tot)*231./AbopPipeRam)+max(ODDrillpipe_inPipeRam1,ODDrillpipe_inPipeRam1Base)
- endif
-
- if (PipeRam1IsOpening) then
- IDPipeRam1=IDPipeRamBase-2.*(NeededVolumePipeRams1- RAM(RNUMBER)%vdis_tot)*231./AbopPipeRam
- endif
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumePipeRams1) then
-
- PipeRam1_closed=1
- !PipeRam1_Situation_forTD= PipeRam1_closed * TD_BOPConnectionPossibility(2)
- pram_reg=pram_reg+RAMS%minloss(RNUMBER,17)
- p_acc= RAM(RNUMBER)%p_acccheck
-
- if (PipeRam1IsClosing) then
- IDPipeRam1=max(ODDrillpipe_inPipeRam1,ODDrillpipe_inPipeRam1Base)
- UpperRamsCloseLED = LedOn
- UpperRamsCloseLEDMine = LedOn
- UpperRamsOpenLED = LedOff
- UpperRamsOpenLEDMine = LedOff
- if (TD_BOPConnectionPossibility(2) == 1) then
- CALL CloseUpperRams ! for C code
- call Set_BlowoutFromAnnular(.true.)
-
-
- PipeRam1_Situation_forTD= 1 ! closed - for TD code
- endif
- endif
-
- if (PipeRam1IsOpening) then
- IDPipeRam1=IDPipeRamBase
- UpperRamsOpenLED = LedOn
- UpperRamsOpenLEDMine = LedOn
- UpperRamsCloseLED = LedOff
- UpperRamsCloseLEDMine = LedOff
- Call OpenUpperRams ! for C code
- PipeRam1_Situation_forTD= 0 ! open - for TD code
- endif
-
- endif
-
- IDPipeRam1Final= IDPipeRam1 ! for output data
-
- endif
-
-
- if (ramtype==3) then !for pipe ram2
- if (PipeRam2IsClosing) then
- IDPipeRam2=(2.*(NeededVolumePipeRams2- RAM(RNUMBER)%vdis_tot)*231./AbopPipeRam)+max(ODDrillpipe_inPipeRam2,ODDrillpipe_inPipeRam1Base)
- endif
-
- if (PipeRam2IsOpening) then
- IDPipeRam2=IDPipeRamBase-2.*(NeededVolumePipeRams2- RAM(RNUMBER)%vdis_tot)*231./AbopPipeRam
- endif
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumePipeRams2) then
-
- PipeRam2_closed=1
- !PipeRam2_closed_withPossibility= PipeRam2_closed * TD_BOPConnectionPossibility(4)
- pram_reg=pram_reg+RAMS%minloss(RNUMBER,17)
- p_acc= RAM(RNUMBER)%p_acccheck
-
- if (PipeRam2IsClosing) then
- IDPipeRam2=max(ODDrillpipe_inPipeRam2,ODDrillpipe_inPipeRam1Base)
- LowerRamsCloseLED = LedOn
- LowerRamsCloseLEDMine = LedOn
- LowerRamsOpenLED = LedOff
- LowerRamsOpenLEDMine = LedOff
- if (TD_BOPConnectionPossibility(4) == 1) then
- CALL CloseLowerRams
- PipeRam2_Situation_forTD= 1 ! closed - for TD code
- endif
- endif
-
- if (PipeRam2IsOpening) then
- IDPipeRam2=IDPipeRamBase
- LowerRamsOpenLED = LedOn
- LowerRamsOpenLEDMine = LedOn
- LowerRamsCloseLED = LedOff
- LowerRamsCloseLEDMine = LedOff
- CALL OpenLowerRams
- PipeRam2_Situation_forTD= 0 ! open - for TD code
- endif
-
- endif
-
- IDPipeRam2Final= IDPipeRam2 ! for output data
-
- endif
-
-
- if (ramtype==4) then !for Choke Line
- if (ChokeLineIsClosing) then
- IDChokeLine=(2.*(NeededVolumeChokeLine- RAM(RNUMBER)%vdis_tot)*231./AbopChokeLine)+max(ODDrillpipe_inChokeLine,ODDrillpipe_inChokeLineBase)
- endif
-
- if (ChokeLineIsOpening) then
- IDChokeLine=IDChokeLineBase-2.*(NeededVolumeChokeLine- RAM(RNUMBER)%vdis_tot)*231./AbopChokeLine
- endif
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumeChokeLine) then
-
- ChokeLine_closed=1
- pram_reg=pram_reg+RAMS%minloss(RNUMBER,17)
- p_acc= RAM(RNUMBER)%p_acccheck
-
- if (ChokeLineIsClosing) then
- IDChokeLine=max(ODDrillpipe_inChokeLine,ODDrillpipe_inChokeLineBase)
- ChokeLineCloseLED = LedOn
- ChokeLineCloseLEDMine = LedOn
- ChokeLineOpenLED = LedOff
- ChokeLineOpenLEDMine = LedOff
- CALL CloseChokeLine
- endif
-
- if (ChokeLineIsOpening) then
- IDChokeLine=IDChokeLineBase
- ChokeLineOpenLED = LedOn
- ChokeLineOpenLEDMine = LedOn
- ChokeLineCloseLED = LedOff
- ChokeLineCloseLEDMine = LedOff
- CALL OpenChokeLine
- endif
-
- endif
-
- endif
-
-
-
- if (ramtype==5) then !for Kill Line
- if (KillLineIsClosing) then
- IDKillLine=(2.*(NeededVolumeKillLine- RAM(RNUMBER)%vdis_tot)*231./AbopKillLine)+max(ODDrillpipe_inKillLine,ODDrillpipe_inKillLineBase)
- endif
-
- if (KillLineIsOpening) then
- IDKillLine=IDKillLineBase-2.*(NeededVolumeKillLine- RAM(RNUMBER)%vdis_tot)*231./AbopKillLine
- endif
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumeKillLine) then
-
- KillLine_closed=1
- pram_reg=pram_reg+RAMS%minloss(RNUMBER,17)
- p_acc= RAM(RNUMBER)%p_acccheck
-
- if (KillLineIsClosing) then
- IDKillLine=max(ODDrillpipe_inKillLine,ODDrillpipe_inKillLineBase)
- KillLineCloseLed = LedOn
- KillLineCloseLedMine = LedOn
- KillLineOpenLed = LedOff
- KillLineOpenLedMine = LedOff
- CALL CloseKillLine
- endif
-
- if (KillLineIsOpening) then
- IDKillLine=IDKillLineBase
- KillLineOpenLed = LedOn
- KillLineOpenLedMine = LedOn
- KillLineCloseLed = LedOff
- KillLineCloseLedMine = LedOff
- CALL OpenKillLine
- endif
-
- endif
-
- endif
-
-
-
-
- !if (ramtype==4) then !for annular
- ! if (AnnularIsClosing) then
- ! IDAnnular=((NeededVolumeAnnular-vdis_tot)*231./AbopAnnular)+ODDrillpipe_inAnnular
- ! endif
- !
- ! if (AnnularIsOpening) then
- ! IDAnnular=IDAnnularBase-(NeededVolumeAnnular-vdis_tot)*231./AbopAnnular
- ! endif
- !
- ! if (vdis_tot>NeededVolumeAnnular) then
- !
- ! Annular_closed=1
- ! p_acc= RAM(RNUMBER)%p_acccheck
- !
- ! if (AnnularIsClosing) then
- ! IDAnnular=ODDrillpipe_inAnnular
- ! AnnularCloseLed = LedOn
- ! AnnularOpenLed = LedOff
- ! endif
- !
- ! if (AnnularIsOpening) then
- ! IDAnnular=IDAnnularBase
- ! AnnularOpenLed = LedOn
- ! AnnularCloseLed = LedOff
- ! endif
- !
- ! endif
- !
- !endif
-
-
- end
-
-
-
- SUBROUTINE bop_codeAnnular(RNUMBER)
-
- USE VARIABLES
- USE CBopControlPanelVariables
- USE CEquipmentsConstants
- USE TD_GeneralData
- implicit none
- INTEGER RNUMBER, I
-
-
- !Pannular_regset=min(AnnularRegulatorSetControl,1700.) ! for changing its set conditions instantaneously
-
- !====================================================
- ! BOP back pressure without DP
- !====================================================
- !if (bop_type==3) then
- !p_annular=510.725-(30.145*IDAnnular)
- p_annular=448-(19.7*IDAnnular)
- ! Q=flow
- ! endif
-
-
-
- RAM(RNUMBER)%clock=0
- !======================Losses============================
- RAM(RNUMBER)%loss_after=0 !initial value
- RAM(RNUMBER)%diffp_ram=1000 !initial value
- RAM(RNUMBER)%loss_before=0
-
- !Q=0.0055; %initial flow rate (m^3/s)
-
- RAM(RNUMBER)%Q=RAM(RNUMBER)%flow
-
- !write(*,*) 'Q1=' , Q
- !write(*,*) 'tol=' , tol
- do while (abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)/ RAM(RNUMBER)%diffp_ram>tolAnnular)
- if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) exit
- ! while abs( RAM(RNUMBER)%diffp_ram- RAM(RNUMBER)%loss_after)>10
- RAM(RNUMBER)%clock= RAM(RNUMBER)%clock+1
-
- if ( RAM(RNUMBER)%clock>20) then
- ! tclock=clock
- tolAnnular=tolzeroAnnular+(floor( RAM(RNUMBER)%clock/10)-1)*.001
- endif
- ! if (clock==1) continue
-
- if ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after> RAM(RNUMBER)%diffp_ram) then
- RAM(RNUMBER)%Q=RAM(RNUMBER)%Q-.1
- elseif ( RAM(RNUMBER)%clock/=1 .and. RAM(RNUMBER)%loss_after<= RAM(RNUMBER)%diffp_ram) then
- RAM(RNUMBER)%Q=RAM(RNUMBER)%Q+.01
-
- endif
-
- !====================Before Regulator=========================
- do i=1,NO_PipingsAnnularLine
- Re_ANNULARline(i)=RAM(RNUMBER)%Q*6.30902e-5*DIAM_ANNULARLINE_INCH(i)*0.0254/(AREA_ANNULARLINE(i)*nu)
-
- enddo
-
-
-
- do i=1,NO_PipingsAnnularLine
- if (Re_ANNULARline(i)<Re_cr) then
- fricANNULAR(i)=64/Re_ANNULARline(i)
- else
-
- fricANNULAR(i)=1/(-1.8*log10((RELROUGH_ANNULARLINE(i)/3.7)**1.11+6.9/Re_ANNULARline(i)))**2
- endif
-
- friclossANNULAR(i)=((fricANNULAR(i)*(wdens*sg*LENGT_ANNULARLINE(i)*(RAM(RNUMBER)%Q*6.30902e-5/AREA_ANNULARLINE(i))**2))/(2*DIAM_ANNULARLINE_INCH(i)*0.0254))/6895
-
- enddo
-
-
-
-
- RAM(RNUMBER)%pipe_loss1=sum(friclossANNULAR(1:6)) !loss before regulator(psi)
-
-
- do i=1,NO_MinorsAnnularLine
- if (LF_ANNULARLINE(i)/=0) then
- minlosspa_ANNULAR(i)=LF_ANNULARLINE(i)*wdens*sg*(RAM(RNUMBER)%Q*6.30902e-5/AREAMINOR_ANNULARLINE(i))**2/2 !(Pa)
- minloss_ANNULAR(i)=minlosspa_ANNULAR(i)/6895 !(psi)
- elseif (CV_ANNULARLINE(i)/=0) then
- minlosspa_ANNULAR(i)=1000*sg*((11.7*RAM(RNUMBER)%Q*6.30902e-5*3600)/(CV_ANNULARLINE(i)))**2 !(pa)
- minloss_ANNULAR(i)=minlosspa_ANNULAR(i)/6895 !(psi)
- else
- minlosspa_ANNULAR(i)=NOTE_ANNULARLINE(i)*1e5 !(pa)
- minloss_ANNULAR(i)=minlosspa_ANNULAR(i)/6895 !(psi)
- endif
- enddo
-
- minloss_ANNULAR(17)= 3.4*RAM(RNUMBER)%Q ! <==== regulator loss (psig)
-
- RAM(RNUMBER)%minor_loss1=sum(minloss_ANNULAR(1:16)) !loss before regulator(psi)
-
- RAM(RNUMBER)%static_loss1=0
-
- RAM(RNUMBER)%kinetic_loss1=sg*wdens*(RAM(RNUMBER)%Q*6.30902e-5/((1/4.)*pi*(.72*0.254e-1)**2))**2/(2*6895) !(psi)
- !.72 for regulator diameter)
-
- RAM(RNUMBER)%loss_before= RAM(RNUMBER)%pipe_loss1+ RAM(RNUMBER)%minor_loss1+ RAM(RNUMBER)%static_loss1+ RAM(RNUMBER)%kinetic_loss1 !(psi)
- !===================after Regulator======================
- ! all in (psi)
- RAM(RNUMBER)%pipe_loss2=sum(friclossANNULAR(7:NO_PipingsAnnularLine)) !7=after regulator<<<<<<<
- RAM(RNUMBER)%minor_loss2=sum(minloss_ANNULAR(17:NO_MinorsAnnularLine)) !17=after regulator<<<<<<<
-
- RAM(RNUMBER)%deltah=H_AnnularBop-H_REGRAM
- ! RAM(RNUMBER)%static_loss2pa= RAM(RNUMBER)%deltah*sg*wdens*gravity; %(pa)
- RAM(RNUMBER)%static_loss2= RAM(RNUMBER)%deltah*sg*wdens*gravity/6895 !(psi)
- RAM(RNUMBER)%kinetic_loss2=0
-
- RAM(RNUMBER)%loss_after= RAM(RNUMBER)%pipe_loss2+ RAM(RNUMBER)%minor_loss2+ RAM(RNUMBER)%static_loss2 !(psi)
- !=======================================================
-
-
-
- !==========================p_regulator======================
- if (Pannular_regset<p_acc- RAM(RNUMBER)%loss_before) then
-
- !!new= Pannular_regset-minloss_ANNULAR(17)
- !
- !CALL Pannular_regDelay%AddToFirst( Pannular_regset-minloss_ANNULAR(17) )
- !CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
- !Pannular_reg= Pannular_regDelay%Last()
-
- Pannular_reg= Pannular_regset-minloss_ANNULAR(17)
-
- ! RAM(RNUMBER)%loss_after= RAM(RNUMBER)%loss_after-minloss(17); %minloss(17)=regulator loss
- else
-
- !!new= p_acc- RAM(RNUMBER)%loss_before-minloss_ANNULAR(17)
- !
- !CALL Pannular_regDelay%AddToFirst( p_acc- RAM(RNUMBER)%loss_before-minloss_ANNULAR(17) )
- !CALL Pannular_regDelay%Remove(Pannular_regDelay%Length())
- !Pannular_reg= Pannular_regDelay%Last()
-
- Pannular_reg= p_acc- RAM(RNUMBER)%loss_before-minloss_ANNULAR(17)
-
- endif
- !===========================================================
-
-
- !====================Flow Rate calculation==================
- RAM(RNUMBER)%diffp_ram=Pannular_reg+minloss_ANNULAR(17)-p_annular
-
-
-
-
-
- end do ! returns correct Q for one timecounter_ram
-
- if (RAM(RNUMBER)%Bottles_Charged_MalfActive==.true.) then
- RAM(RNUMBER)%Q= 5.0 ! gpm
- !write(*,*) 'malffffffffff'
- endif
-
- RAM(RNUMBER)%flow=RAM(RNUMBER)%Q
- !write(*,*) 'minloss_ANNULAR(17)=' , minloss_ANNULAR(17)
- !write(*,*) '%loss_after=' ,RAM(RNUMBER)%loss_after
- !====================p_accumulator for next iterate==================
- ! deltav=Q*1*1000; %delta_t=1sec (lit)
- ! fvr=fvr-deltav; %=fvr_after (lit)
- ! p_acc=0.001178*fvr^3+0.02019*fvr^2+16.1*fvr+2379; %(psia)
- ! vdis_bottles=fvr_tot-fvr; %from the start***needed for p_BOP calculating (lit)
-
- !========for a 10 gal bottle,precharge=1000psig curve BOSCH======
- RAM(RNUMBER)%deltav_bottles=RAM(RNUMBER)%Q*DeltaT_BOP/60. !(galon) delta_t=1sec , Q(gpm)
- fvr=fvr- RAM(RNUMBER)%deltav_bottles !=fvr_after (galon)
- ! b1=993.7; b2=0.164; b3=5.492; b4=0.9796;
- RAM(RNUMBER)%p_acccheck=p_acc
- p_acc=b1*exp(b2*fvr/nobottles)+b3*exp(b4*fvr/nobottles) !(psig)<<<< 8=no. of bottles
- !formula is derived for fvr (galon)
- !vdis_bottles=fvr_tot-fvr
- RAM(RNUMBER)%vdis_bottles= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%deltav_bottles
-
- NoActiveRmas=6.-real(Annular_closed+ShearBop_closed+PipeRam1_closed+PipeRam2_closed+ChokeLine_closed+KillLine_closed)
- RAM(RNUMBER)%vdis_elecp= RAM(RNUMBER)%vdis_elecp+(deltav_elecp/NoActiveRmas) !overal discharged
- RAM(RNUMBER)%fvr_air= RAM(RNUMBER)%fvr_air+(deltav_air/NoActiveRmas) !=fvr_after (galon) for next timecounter_ram
-
-
- RAM(RNUMBER)%vdis_tot= RAM(RNUMBER)%vdis_bottles+ RAM(RNUMBER)%fvr_air+ RAM(RNUMBER)%vdis_elecp !overal
- !write(*,*) 'RAM(RNUMBER)%vdis_tot=' , RAM(RNUMBER)%vdis_tot!, vdis_bottles,fvr_air, vdis_elecp !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
- !write(*,*) 'a)IDAnnular=' , IDAnnular
- ! WRITE(*,*) 'a)NeededVolumeAnnular=' , NeededVolumeAnnular
- !
- ! write(*,*) 'AbopAnnular= ' , AbopAnnular
- ! write(*,*) 'max=' , max(ODDrillpipe_inAnnular,ODDrillpipe_inAnnularBase)
-
- !if (ramtype==4) then !for annular
- if (AnnularIsClosing) then
- IDAnnular=(2.*(NeededVolumeAnnular- RAM(RNUMBER)%vdis_tot)*231./AbopAnnular)+max(ODDrillpipe_inAnnular,ODDrillpipe_inAnnularBase)
- !write(*,*) 'b)IDAnnular=' , IDAnnular
- endif
-
- if (AnnularIsOpening) then
- IDAnnular=IDAnnularBase-2.*(NeededVolumeAnnular- RAM(RNUMBER)%vdis_tot)*231./AbopAnnular
- endif
-
- if ( RAM(RNUMBER)%vdis_tot>NeededVolumeAnnular) then
-
- Annular_closed=1
- !Annular_closed_withPossibility= Annular_closed * TD_BOPConnectionPossibility(1)
- !pram_reg=pram_reg+minloss_ANNULAR(17)
- Pannular_reg= Pannular_reg+minloss_ANNULAR(17)
-
- p_acc= RAM(RNUMBER)%p_acccheck
- if (AnnularIsClosing) then
-
- IDAnnular=max(ODDrillpipe_inAnnular,ODDrillpipe_inAnnularBase)
- AnnularCloseLed = LedOn
- AnnularCloseLedMine = LedOn
-
- AnnularOpenLed = LedOff
- AnnularOpenLedMine = LedOff
-
- if (TD_BOPConnectionPossibility(1) == 1) then
- CALL CloseAnnular
- Annular_Situation_forTD= 1 ! closed - for TD code
- endif
- endif
-
-
-
- if (AnnularIsOpening) then
-
- IDAnnular=IDAnnularBase
- AnnularOpenLed = LedOn
- AnnularOpenLedMine = LedOn
-
- AnnularCloseLed = LedOff
- AnnularCloseLedMine = LedOff
-
- CALL OpenAnnular
- Annular_Situation_forTD= 0 ! open - for TD code
- endif
-
- endif
-
- IDAnnularFinal= IDAnnular ! for output data
- !endif
-
-
- end
|