!*************************************************************************************!
! TITLE: CFVR5244 - Isostatic and hiperestatic checking on isostatic solid
! SUBTITLE: Rectangular cross section.
!
! DESCRIPTION: The model is a prestressed beam 15 m length.
! DESCRIPTION:
! DESCRIPTION: The beam is made of C16/20 concrete and the tendons are made of Gr250 steel.
! DESCRIPTION:
! DESCRIPTION: The section is rectangular 1 x 0.5, with reinforcement of S400 steel.
! DESCRIPTION:
! DESCRIPTION: Load states:
! DESCRIPTION:
! DESCRIPTION: - LS 1: Self weight
! DESCRIPTION:
! DESCRIPTION: - LS 2: Self weight + Prestressing loads
! DESCRIPTION:
! DESCRIPTION: - LS 3: Transverse weight
! DESCRIPTION:
! DESCRIPTION: - LS 4: Prestressing loads
! DESCRIPTION:
! DESCRIPTION: The aim of the example is to verify the calculation of prestressing losses.
! DESCRIPTION:
! DESCRIPTION: This example is based on "Prestressed concrete, a fundamental approach",
! DESCRIPTION: 4<sup>th</sup> edition, page 16.
!
! ELEMENT TYPE: SOLID45
! MODULES: PRSC
! UNITS: SI
! KEYWORD1: Beam
! KEYWORD2: Tendon
! KEYWORD3: Cross Section
! KEYWORD4: Prestressed Concrete
! KEYWORD5: Prestressing Losses
!
!*************************************************************************************!
   FINISH
   ~CFCLEAR,,1
   ~CFACTIV,PRSC,Y
   NomFile='CFVR5244'
 /TITLE,%NomFile%, I&H CHECKING, ISOST SOLID, RECT SECTION

! -------------------------------------------------------------------------------------
! Initial data
! -------------------------------------------------------------------------------------
! CivilFEM SETUP
  ~UNITS,SI
  ~CODESEL,,EC2-91,EC2-91
  ~CFACTIV,PRSC,Y

! Preprocessor
  /PREP7

! Material Definition
  ~CFMP,1,LIB,CONCRETE,EC2,C16/20
  ~CFMP,2,LIB,REINF,CEB,S400
  ~CFMP,3,LIB,PREST,ASTMA416,Gr250

  ! Parameters for not considering prestressing losses.
  ~CFMP,3,Prest,MU,,0
  ~CFMP,3,Prest,K ,,0
  ~CFMP,3,Prest,A ,,0

! Element Type Definition
  ET,1,solid45

! Cross-section definition
  ~CSECDMS,1,REC,1,1 ,0.5

! Model Construction
  K,1
  K,2,15
  L,1,2
  LSEL,NONE
  ~SEC2DOU,1,0,1
  LESIZE,ALL,,,1
  VDRAG,ALL,,,,,,1
  H_ELEMS = 8
  SIZ = 15/(H_ELEMS*2)
  ESIZE,SIZ
  LSEL,ALL
  VMESH,ALL

  MEDCUT = H_ELEMS+1
  ENDCUT   = H_ELEMS*2+1
  *DO,I,0,H_ELEMS*2
    LOCAL,11+I,0,I*SIZ
    NSEL,S,LOC,X,0
    ESLN,S
    *IF,I,EQ,0,THEN
      NSEL,S,LOC,X, SIZ
    *ELSE
      NSEL,S,LOC,X,-SIZ
    *ENDIF
    ESLN,R
    NSEL,S,LOC,X,0
    ~SLDSEC, I+1, 1, 11+I  
  *ENDDO
 
  CSYS,0
  NSEL,S,LOC,X,15
  NSEL,R,LOC,Y,0
  D,ALL,,,,,,UY,UZ  

  CSYS,0

  NSEL,S,LOC,X,0
  NSEL,R,LOC,Y,0
  D,ALL,ALL

  ALLSEL

! Support beam construction

  AREA = 0.01
  C_DIAMETER = 0.15
  ~SBSMDEF,1,H_ELEMS*2+1

  ~PCEPDEF,1,       1,     0,0
  ~PCEPDEF,2,medcut,-0.400,0
  ~PCEPDEF,3,  endcut,     0,0

  ~PCPPDEF,1,       1,     0,0
  ~PCPPDEF,3,  endcut,     0,0

  Papp = 862207
  ~PCTNDEF,1,3,area,c_diameter,Papp  ,Papp  ,0

  ~PCTNMDF,1,EADD,1.
  ~PCTNMDF,1,EADD,2.
  ~PCTNMDF,1,EADD,3.
  ~PCTNMDF,1,PADD,1.
  ~PCTNMDF,1,PADD,3.
  ~PCTNMDF,1,METHOD,1

  ~PCTNMDF,1,EPAROUT,1,0
  ~PCTNMDF,1,EPARIN,2,0

  ~PCLOSS,0,0,0,0.8,

/SOLU
  ACEL,,9.81
  SOLVE               ! LS 1: Self weight

  ~PCPL               ! Prestressing forces
  SOLVE               ! LS 2: SW + Prestressing

  ~PCDEL              ! Prestressing forces delete
  ACEL,,,9.81         ! "Transverse" weight
  SOLVE               ! LS 3: SWT

  ACEL,
  ~PCPL               ! Prestressing forces
  SOLVE               ! LS 4: Prestressing

/POST1

!--------------------------------------------------------------------------------------
! DATA CHECK
!--------------------------------------------------------------------------------------
! Data comparison number
  NComp = 21
  NComp_ch = 0

! Matrix dim.
  *DIM,LABEL,CHAR,Ncomp,1
  *DIM,LABEL_CH,CHAR,Ncomp_ch,1
  *DIM,VALUE,,Ncomp,3
  *DIM,VALUE_CH,CHAR,Ncomp_ch,3
  *DIM,TOLER,,Ncomp,2

! Labels, Correct data, obtained data
!--------------------------------------------------------------------------------------
  ~CFSET,,1
  LABEL( 1) = 'KPRES1' $  VALUE( 1,1) =  0.0           $  ~CFGET,VALUE( 1,2),PRSCONC,,KPRES
  ~CFSET,,2
  LABEL( 2) = 'KPRES2' $  VALUE( 2,1) =  1             $  ~CFGET,VALUE( 2,2),PRSCONC,,KPRES
  ~CFGET,aux1,SOLID,medcut,FORCE,HMZ
  ~CFGET,aux2,SOLID,medcut,FORCE,IMZ
  LABEL( 3) = 'HMZ/IMZ'$  VALUE( 3,1) = -1             $  VALUE( 3,2)=aux1/aux2
  LABEL( 4) = 'FY'     $  VALUE( 4,1) =  0.0           $  ~CFGET,VALUE( 4,2),SOLID,medcut,FORCE, FY
  LABEL( 5) = 'IFY'    $  VALUE( 5,1) =  0.0           $  ~CFGET,VALUE( 5,2),SOLID,medcut,FORCE,IFY

  ~CFSET,,3
  LABEL( 6) = 'KPRES3' $  VALUE( 6,1) =  0.0           $  ~CFGET,VALUE( 6,2),PRSCONC,,KPRES
  ~CFSET,,1
  LABEL( 7) = 'MZ'     $  VALUE( 7,1) =  344882.8125  $  ~CFGET,VALUE( 7,2),SOLID,medcut,FORCE, MZ
  ~CFSET,,3
  LABEL( 8) = 'IMY'    $  VALUE( 8,1) =  0.0           $  ~CFGET,VALUE( 8,2),SOLID,medcut,FORCE,IMY

  ~CFSET,,4
  LABEL( 9) = 'KPRES4' $  VALUE( 9,1) =  1             $  ~CFGET,VALUE( 9,2),PRSCONC,,KPRES
  ~CFGET,aux1,SOLID,medcut,FORCE,HMZ
  ~CFGET,aux2,SOLID,medcut,FORCE,IMZ
  LABEL(10) = 'Ratio MZ'	$  VALUE(10,1) =  1.00  $  VALUE(10,2)=ABS(aux2/(aux2+aux1))

  ~CFGET,aux1,SOLID,medcut,FORCE,HFX
  ~CFGET,aux2,SOLID,medcut,FORCE,IFX
  LABEL(11) = 'Ratio FX' $  VALUE(11,1) =  1.00  $  VALUE(11,2)=ABS(aux2/(aux1+aux2))
  ~CFGET,aux1,SOLID,medcut,FORCE,HFY
  ~CFGET,aux2,SOLID,medcut,FORCE,IFY
  LABEL(12) = 'Ratio FY' $ VALUE(12,1) =  0.00   $  VALUE(12,2)=ABS(aux2/aux1)
  LABEL(13) = 'RFX1'    $ VALUE(13,1) =  0.0           $  *GET,VALUE(13,2),NODE,1,RF,FX
  LABEL(14) = 'RFY1'    $ VALUE(14,1) =  0.0           $  *GET,VALUE(14,2),NODE,1,RF,FY
  LABEL(15) = 'RFZ1'    $ VALUE(15,1) =  0.0           $  *GET,VALUE(15,2),NODE,1,RF,FZ
  LABEL(16) = 'RFY2'    $ VALUE(16,1) =  0.0           $  *GET,VALUE(16,2),NODE,2,RF,FY
  LABEL(17) = 'RFZ2'    $ VALUE(17,1) =  0.0           $  *GET,VALUE(17,2),NODE,2,RF,FZ

  a_parab = 0.0071111111
  LABEL(18) = 'YP'      $  VALUE(18,1) = a_parab*(-7.5+7.5/h_elems)**2 -0.4 $  ~CFGET,VALUE(18,2),PRSCONC,,TENDON,COORD,Y,1,2
  LABEL(19) = 'ZP'      $  VALUE(19,1) = 0  $  ~CFGET,VALUE(19,2),PRSCONC,,TENDON,COORD,Z,1,2
  LABEL(20) = 'SXYP'    $  VALUE(20,1) = 2*a_parab*(-7.5+7.5/h_elems)  $  ~CFGET,VALUE(20,2),PRSCONC,,TENDON,COORD,SXY,1,2

  ~CFSET,,2
  LABEL(21) = 'UYMAX'    $ VALUE(21,1) =  0.984E-5      $  *GET,VALUE(21,2),NODE,20,U,Y

! Warning and error tolerances
  TOLER(  1,1) = 1E-02   $  TOLER(  1,2) = 1E-02 
  TOLER(  2,1) = 1E-02   $  TOLER(  2,2) = 1E-02 
  TOLER(  3,1) = 1E-02   $  TOLER(  3,2) = 1E-02   
  TOLER(  4,1) = 1E-00   $  TOLER(  4,2) = 1E-00	!  FY value is taken as null compared to initial force
  TOLER(  5,1) = 1E-02   $  TOLER(  5,2) = 1E-02 	!  IFY value must be null
  TOLER(  6,1) = 1E-02   $  TOLER(  6,2) = 1E-02 
  TOLER(  7,1) = 1E+05   $  TOLER(  7,2) = 1E+05 
  TOLER(  8,1) = 1E-02   $  TOLER(  8,2) = 1E-02 	!  IMY value must be null
  TOLER(  9,1) = 1E-02   $  TOLER(  9,2) = 1E-02 
  TOLER( 10,1) = 1E-02   $  TOLER( 10,2) = 1E-02 	! HMZ value is taken as null compared to initial force
  TOLER( 11,1) = 1E-03   $  TOLER( 11,2) = 1E-03 	! HFX value is taken as null compared to initial force
  TOLER( 12,1) = 1E-03   $  TOLER( 12,2) = 1E-03 	! HFY value is taken as null compared to initial force
  TOLER( 13,1) = 1E-03   $  TOLER( 13,2) = 1E-03	! Nodal reaction forces FX must be null
  TOLER( 14,1) = 1E-03   $  TOLER( 14,2) = 1E-03    ! Nodal reaction forces FY must be null
  TOLER( 15,1) = 1E-03   $  TOLER( 15,2) = 1E-03    ! Nodal reaction forces FZ must be null
  TOLER( 16,1) = 1E-03   $  TOLER( 16,2) = 1E-03    ! Nodal reaction forces FY must be null
  TOLER( 17,1) = 1E-03   $  TOLER( 17,2) = 1E-03    ! Nodal reaction forces FZ must be null
  TOLER( 18,1) = 1E-03   $  TOLER( 18,2) = 1E-03 
  TOLER( 19,1) = 1E-03   $  TOLER( 19,2) = 1E-03 	!  ZP value must be null
  TOLER( 20,1) = 1E-03   $  TOLER( 20,2) = 1E-03 
  TOLER( 21,1) = 1E-06   $  TOLER( 21,2) = 1E-06 
!--------------------------------------------------------------------------------------
! Results comparison
!--------------------------------------------------------------------------------------
  COMPARA.MAC
