!*************************************************************************************!
! TITLE: CFVR0854 - Linear combination test with prestressed concrete
! SUBTITLE: Example to check the linear combinations utility with prestressed concrete
!
! DESCRIPTION: This example checks the functionality of the combinations module with prestressed concrete.
! DESCRIPTION:
! DESCRIPTION:
! DESCRIPTION: The model is a concrete slab bridge, with a straight path.
! DESCRIPTION:
! DESCRIPTION: Three load cases are defined:
! DESCRIPTION:
! DESCRIPTION: - The first one is self weight with prestressing effects.
! DESCRIPTION:
! DESCRIPTION: - The second one is a surface load of 100kN/m<sup>2</sup> on half of the model.
! DESCRIPTION:
! DESCRIPTION: - The third one is a surface load of 100kN/m<sup>2</sup> on the other half of the model.
! DESCRIPTION:
! DESCRIPTION:
! DESCRIPTION: The combination rules defined are:
! DESCRIPTION:
! DESCRIPTION: - Combination rule 1: Addition with variable coefficients [1.0 or 2.0 * H1 + 1.0 or 2.0 * H2]
! DESCRIPTION:
! DESCRIPTION: - Combination rule 2: Addition [Combination 1 + H3]
! DESCRIPTION:
!
! ELEMENT TYPE: Beam44
! MODULES: PRSC NLBR
! UNITS: SI
! KEYWORD1: Cross Section
! KEYWORD2: Beam & Shell Properties
! KEYWORD3: Beam
! KEYWORD4: Bridges
! KEYWORD5: Prestressed Concrete
! KEYWORD6: Combinations
!*************************************************************************************!
  FINISH
  ~CFCLEAR,,1 
 AnsLic='ansys'

  NomFile='CFVR0854'
  /TITLE, %NomFile%, Linear combination test with prestressed concrete
! ---------------------------------------------------------------------------------
! Model definition and solve
! ---------------------------------------------------------------------------------
~CFACTIV,NLBR,Y
~CFACTIV,PRSC,Y
~UNITS,SI

/PREP7

! Materials
  ~CFMP,1,LIB,CONCRETE,EHE,HA-35 ! HA-35 concrete
  ~CFMP,2,LIB,REINF,EC2,S500     ! S-500 reinforcing steel
  ~CFMP,3,LIB,PREST,EHE,Y1860S7  ! Y1860S7 prestressing steel
  ~CFMP,3,Prest,MU,,0.21         ! Friction coefficient
  ~CFMP,3,Prest,K ,,1.26e-002    ! Unintentional friction
  ~CFMP,3,Prest,A ,,5e-003       ! Anchorage slip

! Element type
  ET,1,BEAM44
! Bridge section
 ~BRSSLAB,1,TF,1,2.7,4 ,8,1.2,0.9,0.2
 ~BRHL,1,C,-0.65,-0.6,0.4,,2,1.2   ! Hollows in the slab

! Bridge layout: Bridge definition
 ~BRINIP,1,0,0,0,0,0
 ~BRADDPL,99.5,153.5   ! Bridge layout in plan view
 ~BRADDEL,99.5,153.5   ! Bridge layout in elevation view

 ~BRSKTCH,5        ! Plots the bridge axis (MP’s path)

! Model definition
  ! Support 1
  ~BRDEF, 99.5 ,1,,,,,,2  ! Solid Holes
  ~BRDEF, 100  ,1,,,,,,2  ! Solid Holes
  ~BRDEF, 100.5,1,,,,,,0  ! With Holes
  ! Support 2
  ~BRDEF, 111.5,1,,,,,,2  ! Solid Holes
  ~BRDEF, 112  ,1,,,,,,2  ! Solid Holes
  ~BRDEF, 112.5,1,,,,,,0  ! With Holes
  ! Center Span
  ~BRDEF, 126.5,1,,,,,,0  ! With Holes
  ! Support 3
  ~BRDEF, 140.5,1,,,,,,2  ! Solid Holes
  ~BRDEF, 141  ,1,,,,,,2  ! Solid Holes
  ~BRDEF, 141.5,1,,,,,,0  ! With Holes
  ! Support 4
  ~BRDEF, 149  ,1,,,,,,0  ! With Holes
  ~BRDEF, 152.5,1,,,,,,2  ! Solid Holes
  ~BRDEF, 153  ,1,,,,,,2  ! Solid Holes
  ~BRDEF, 153.5,1,,,,,,2  ! Solid Holes

 ~BRGEN,B, , , 1.0,   ! Generates the bridge model with beam elements

! Boundary conditions
  NSEL,S,LOC,Y,0
  NSEL,R,LOC,X,0.5
    D,ALL,UY,0
    D,ALL,UZ,0
  NSEL,S,LOC,Y,0
  NSEL,R,LOC,X,12
    D,ALL,UY,0
    D,ALL,UZ,0
  NSEL,S,LOC,Y,0
  NSEL,R,LOC,X,41
    D,ALL,UY,0
    D,ALL,UZ,0
  NSEL,S,LOC,Y,0
  NSEL,R,LOC,X,53
    D,ALL,UX,0
    D,ALL,UY,0
    D,ALL,UZ,0
    D,ALL,ROTX,0
  ALLSEL

! Support Beam
  LOCAL,11,0,0,0,0,0,+90
  ~SBBMDEF,1   ! Captures the support beam from the model

! Points definition
  ~PCPPDEF,  1,  1,  0.09, 0, 0.5
  ~PCPPDEF,  2,  1, -0.09, 0, 0.5
  ~PCPPDEF,  3,  1,  1.1 , 0, 0.5
  ~PCPPDEF,  4,  1, -1.1 , 0, 0.5
  ~PCPPDEF,  5,  1,  1.3 , 0, 0.5
  ~PCPPDEF,  6,  1, -1.3 , 0, 0.5
  ~PCPPDEF,  7, 60,  0.09, 0, 0.5
  ~PCPPDEF,  9, 60, -0.09, 0, 0.5
  ~PCPPDEF, 11, 60,  1.1 , 0, 0.5
  ~PCPPDEF, 13, 60, -1.1 , 0, 0.5
  ~PCPPDEF, 15, 60,  1.3 , 0, 0.5
  ~PCPPDEF, 17, 60, -1.3 , 0, 0.5
  ~PCEPDEF,  1,  1, -0.613, 0, 0.5
  ~PCEPDEF,  2,  6, -0.613, 0, 0.5
  ~PCEPDEF,  3, 15, -0.135, 0, 0.5
  ~PCEPDEF,  4, 30, -1.065, 0, 0.5
  ~PCEPDEF,  5,  1, -0.212, 0, 0.5
  ~PCEPDEF,  6,  6, -0.212, 0, 0.5
  ~PCEPDEF,  7, 55, -0.212, 0, 0.5
  ~PCEPDEF,  8, 60, -0.212, 0, 0.5
  ~PCEPDEF,  9, 45, -0.135, 0, 0.5
  ~PCEPDEF, 10, 55, -0.613, 0, 0.5
  ~PCEPDEF, 11, 60, -0.613, 0, 0.5

! Tendon definition
  *DO,I,1,6
    ~PCTNDEF, I, 3,0.0021,0.09,3.125e6,2.930e6
  *ENDDO

! Tendon 1 trajectory
  ~PCTNMDF, 1, EADD, 1.
  ~PCTNMDF, 1, EADD, 2.
  ~PCTNMDF, 1, EADD, 3.
  ~PCTNMDF, 1, EADD, 4.
  ~PCTNMDF, 1, EADD, 9.
  ~PCTNMDF, 1, EADD,10.
  ~PCTNMDF, 1, EADD,11.
  ~PCTNMDF, 1, PADD, 1.
  ~PCTNMDF, 1, PADD, 7.

! Tendon 2 trajectory
  ~PCTNMDF, 2, EADD, 5.
  ~PCTNMDF, 2, EADD, 6.
  ~PCTNMDF, 2, EADD, 3.
  ~PCTNMDF, 2, EADD, 4.
  ~PCTNMDF, 2, EADD, 9.
  ~PCTNMDF, 2, EADD, 7.
  ~PCTNMDF, 2, EADD, 8.
  ~PCTNMDF, 2, PADD, 2.
  ~PCTNMDF, 2, PADD, 9.

! Tendon 3 trajectory
  ~PCTNMDF, 3, EADD, 1.
  ~PCTNMDF, 3, EADD, 2.
  ~PCTNMDF, 3, EADD, 3.
  ~PCTNMDF, 3, EADD, 4.
  ~PCTNMDF, 3, EADD, 9.
  ~PCTNMDF, 3, EADD,10.
  ~PCTNMDF, 3, EADD,11.
  ~PCTNMDF, 3, PADD, 3.
  ~PCTNMDF, 3, PADD,11.

! Tendon 4 trajectory
  ~PCTNMDF, 4, EADD, 1.
  ~PCTNMDF, 4, EADD, 2.
  ~PCTNMDF, 4, EADD, 3.
  ~PCTNMDF, 4, EADD, 4.
  ~PCTNMDF, 4, EADD, 9.
  ~PCTNMDF, 4, EADD,10.
  ~PCTNMDF, 4, EADD,11.
  ~PCTNMDF, 4, PADD, 4.
  ~PCTNMDF, 4, PADD,13.

! Tendon 5 trajectory
  ~PCTNMDF, 5, EADD, 5.
  ~PCTNMDF, 5, EADD, 6.
  ~PCTNMDF, 5, EADD, 3.
  ~PCTNMDF, 5, EADD, 4.
  ~PCTNMDF, 5, EADD, 9.
  ~PCTNMDF, 5, EADD, 7.
  ~PCTNMDF, 5, EADD, 8.
  ~PCTNMDF, 5, PADD, 5.
  ~PCTNMDF, 5, PADD,15.

! Tendon 6 trajectory
  ~PCTNMDF, 6, EADD, 5.
  ~PCTNMDF, 6, EADD, 6.
  ~PCTNMDF, 6, EADD, 3.
  ~PCTNMDF, 6, EADD, 4.
  ~PCTNMDF, 6, EADD, 9.
  ~PCTNMDF, 6, EADD, 7.
  ~PCTNMDF, 6, EADD, 8.
  ~PCTNMDF, 6, PADD, 6.
  ~PCTNMDF, 6, PADD,17.

! Modifies the distance ratio of the inflection point in elevation view
  ~PCEPMDF,2,INFDIST,0.8
  ~PCEPMDF,6,INFDIST,0.8
  ~PCEPMDF,3,INFDIST,0.2
  ~PCEPMDF,4,INFDIST,0.8
  ~PCEPMDF,9,INFDIST,0.2

! Post-prestressed method: Prestressed from the initial end (cut=1)
  ~PCTNMDF,1,METHOD,1
  ~PCTNMDF,2,METHOD,1
  ~PCTNMDF,3,METHOD,1
  ~PCTNMDF,4,METHOD,1
  ~PCTNMDF,5,METHOD,1
  ~PCTNMDF,6,METHOD,1

/SOLU
! Self Weight and prestressing
/TITLE,LS1 Self Weight and prestressing
  ! Final Prestressing
  ~PCLOSS,1000000
  ~PCPL
  ! Self Weight
  ACEL,,,9.81
  SOLVE
  ! Delete loads
  ACEL,
  ~PCDEL

! Surface load
/TITLE,LS2 surface load
  *DO,I,1,12
    SFBEAM,I,2,PRES,100000
  *ENDDO
  SOLVE
  SFEDELE,ALL,ALL,ALL
  FDELE,ALL,ALL

! Surface load
/TITLE,LS3 Surface load
  *DO,I,13,43
    SFBEAM,I,2,PRES,100000
  *ENDDO
  SOLVE
  SFEDELE,ALL,ALL,ALL
  FDELE,ALL,ALL

/POST1
! ---------------------------------------------------------------------------------
! Definition and solving of combinations
! ---------------------------------------------------------------------------------
~CMBCLR
! Combinations definition
  ! Combination 1: ADDITION [H1+H2]
      ~CMBDEF,1,ADDVC,2,
      ~STSTDEF,1,1,LSTEP,1         ! H1: LS1
      ~STSTDEF,1,2,LSTEP,2         ! H2: LS2
      ~STSTCFT,1,1,1.00,2.00
      ~STSTCFT,1,2,2.00,1.00
  ! Combination 2: ADDITION CMB1+H3 = [H1+H2]+H3
      ~CMBDEF,2,ADD,2
      ~STSTDEF,2,1,CMB,1           ! Cmb1
      ~STSTDEF,2, 2,LSTEP,3        ! H3: LS3
      ~STSTCFT,2,1,1.00
      ~STSTCFT,2,2,1.00
    ~LINCMB

!--------------------------------------------------------------------------------------
! DATA CHECK
!--------------------------------------------------------------------------------------
! Data comparison number
  NComp =4
  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

! Correct values
! ---------------------------------------------------------------------------------
  ! My Element 28 End J
  ~CFSET,,1
  ~CFGET,VAL1, ELEMENT,28, FORCE, MZ, J
  ~PLLSSTR,SX,1
  *GET,SVAL1,ELEM,4,ETAB,CFETAB_J
  ~CFSET,,2
  ~CFGET,VAL2, ELEMENT,28, FORCE, MZ, J
  ~PLLSSTR,SX,1
  *GET,SVAL2,ELEM,4,ETAB,CFETAB_J
  ~CFSET,,3
  ~CFGET,VAL3, ELEMENT,28, FORCE, MZ, J
  ~PLLSSTR,SX,1
  *GET,SVAL3,ELEM,4,ETAB,CFETAB_J

  VALUE( 1,1) = 2*(VAL1)+2*(VAL2)               ! 2LS1+2LS2   Minimum value
  VALUE( 2,1) = VAL1+VAL2+VAL3                  ! LS1+LS2+SL3 Maximum Value
  ! Concomitant SX on element 4 (beam)
  VALUE( 3,1) = 2*(SVAL1)+2*(SVAL2)             ! 2LS1+2LS2
  VALUE( 4,1) = SVAL1+SVAL2+SVAL3               ! LS1+LS2+LS3

! Obtained values
! ---------------------------------------------------------------------------------
 ~CFSET,,4
 ~CFGET,ValAux, ELEMENT,28, FORCE, MZ, J
  MaxLS = 4
  MinLS = 4
  MinVal = ValAux
  MaxVal = ValAux
  *DO,II,5,11
    ~CFSET,,II
    ~CFGET,ValAux, ELEMENT,28, FORCE, MZ, J
    *IF,MinVal,GT,ValAux,THEN
      MinVal = ValAux
      MinLS = II
    *ENDIF
    *IF,MaxVal,LT,ValAux,THEN
      MaxVal = ValAux
      MaxLS = II
    *ENDIF
  *ENDDO

! Test 1 and 3:
  ~CFSET,,MinLS
  ~CFGET,VALUE(1,2), ELEMENT,28, FORCE, MZ, J
  ~PLLSSTR,SX,1
  *GET,VALUE(3,2),ELEM,4,ETAB,CFETAB_J
! Test 2 and 4:
  ~CFSET,,MaxLS
  ~CFGET,VALUE(2,2), ELEMENT,28, FORCE, MZ, J
  ~PLLSSTR,SX,1
  *GET,VALUE(4,2),ELEM,4,ETAB,CFETAB_J


! Labels
! ---------------------------------------------------------------------------------
  LABEL( 1) ='Min_MY'
  LABEL( 2) ='Max_MY'
  LABEL( 3) ='Conc_SX'
  LABEL( 4) ='Conc_SX'

! Warning and error tolerances
  TOLER( 1, 1)= 1E1        $   TOLER( 1, 2)= 1E2
  TOLER( 2, 1)= 1E1        $   TOLER( 2, 2)= 1E2
  TOLER( 3, 1)= 1E1        $   TOLER( 3, 2)= 1E2
  TOLER( 4, 1)= 1E1        $   TOLER( 4, 2)= 1E2

! ---------------------------------------------------------------------------------
! Results comparison
! ---------------------------------------------------------------------------------
  COMPARA.MAC
