TALK=T;RUN(1,1) x-direction tensile stress in a cube; s001.htm
```
TALK=f;RUN(1,1)
DISPLAY
A cubical block is subjected to a tensile force, under three
possible lateral-constraint conditions:
1. no constraint
2. lateral displacement in y and z directions prevented
3. lateral displacement prevented only in y direction

The boolean variable 'direct' toggles which end is fixed and which
is pulled.

The stresses and strains are calculated; and their textbook
values are also printed for comparison.

One fluid cell is provided at each to facilitate application
of boundary conditions
ENDDIS
************************************************************
Group 1. Run Title and Number
************************************************************

TEXT(x-direction mechanical stress in cube
integer(caseno)
mesg(caseno = 1        ! 1=x-direction tension, y & z free
mesg(caseno = 2        !     ditto            , y & z fixed
mesg(caseno = 3        !     ditto            , y fixed, z free
caseno=1
mesg(caseno=:caseno: Enter 1, 2 or 3 or blank
if(caseno.lt.1) then
endif
if(caseno.gt.3) then
endif
caseno
real(appstr)
appstr = 1.e9     ! applied stress
appstr
boolean(direct)
direct=t
direct
************************************************************
Group 2. Time dependence
************************************************************
Group 3. X-Direction Grid Spacing
CARTES  =    t
NX      =         10
NX      =         5
XULAST  = 1.0*(NX+2)
************************************************************
Group 4. Y-Direction Grid Spacing
NY      = 1
YVLAST=1.0
#UNIGRID
************************************************************
Group 5. Z-Direction Grid Spacing
NZ      =         1
ZWLAST  = 1.000000E+00
************************************************************
Group 7. Variables: STOREd,SOLVEd,NAMEd
ONEPHS  =    T
SOLVE(P1,U1)
STORE(PRPS,DEN1,ENUL,DVO1,DRH1)
STORE(PTH)        ! TH signifies 'theoretical' i.e. 'textbook'
STORE(STRX,SXTH)
STORE(STRY,SYTH)
STORE(STRZ,SZTH)
STORE(EPSX,EXTH)
STORE(EPSY,EYTH)
STORE(EPSZ,EZTH)
Group 8. iteration numbers etc
RESREF(U1)=0.0
************************************************************
GROUP 9. PROPERTIES
CSG10='Q1'           ! signal use of the following properties line
! which correspond to steel
MATFLG=T;NMAT=1
160    7800.0    0.3       473.0   43.0    0.37e-5   0.5E-11
REAL(YOUNG, POISSON)
POISSON = 0.3          ! must conform with matflg value
YOUNG   = 1/(0.5E-11)  ! must conform with matflg value
************************************************************
GROUP 11. INITIAL VALUES
FIINIT(PRPS)=0
FIINIT(P1)=0.0
FIINIT(U1)=0.0
FIINIT(V1)=0.0
FIINIT(W1)=0.0
FIINIT(EXTH)=-1.234E-11  ! to print as none
FIINIT(EYTH)=-1.234E-11  ! to print as none
FIINIT(EZTH)=-1.234E-11  ! to print as none
FIINIT(SXTH)=-1.234E-11  ! to print as none
FIINIT(SYTH)=-1.234E-11  ! to print as none
FIINIT(SZTH)=-1.234E-11  ! to print as none
PATCH(BLOCK,INIVAL,2,NX-1,1,1,1,1,1,1)
INIT (BLOCK,PRPS,FIXVAL,160)

************************************************************
GROUP 13. BOUNDARY & SPECIAL SOURCES

IF(DIRECT) THEN
PATCH(WES,WEST,1,1,1,1,1,1,1,1)
COVAL(WES,U1,FIXVAL, 0.0)

PATCH(EFORCE,EAST,NX-1,NX-1,1,1,1,1,1,1)
COVAL(EFORCE,U1,FIXFLU,APPSTR)

ELSE

PATCH(EAS,EAST,NX-1,NX-1,1,1,1,1,1,1)
COVAL(EAS,U1,FIXVAL, 0.0)

PATCH(EFORCE,EAST,1,1,1,1,1,1,1,1)
COVAL(EFORCE,U1,FIXFLU,-APPSTR)
ENDIF
************************************************************
GROUP 15. TERMINATE SWEEPS
LSWEEP  = 100
ISG21   = 20   ! to ensure at least isg21 sweeps
************************************************************
GROUP 17. RELAXATION
#CONPROM
************************************************************
GROUP 19. DATA TRANSMITTED TO GROUND
STRA    =    T  To activate stress analysis
************************************************************
GROUP 23.FIELD PRINT-OUT & PLOT CONTROL
NYPRIN=1
TSTSWP=-1
#MAXABS
#ENDPAUSE
REAL(PTH,EXTH,EYTH,EZTH,SXTH,SYTH,SZTH,TERM)
Formulae for the theoretical values
IF(CASENO.EQ.1) THEN
SXTH=APPSTR
EXTH=APPSTR/YOUNG
EYTH=-EXTH*POISSON
EZTH=-EXTH*POISSON
SYTH=0.0
SZTH=0.0
ENDIF

IF(CASENO.EQ.2) THEN
EYTH=0.0
EZTH=0.0
TERM=APPSTR
EXTH=(APPSTR/YOUNG)*(1+POISSON)*(1-2*POISSON)/(1-POISSON)
SXTH=TERM
SYTH=TERM*POISSON/(1-POISSON)
SZTH=TERM*POISSON/(1-POISSON)
ENDIF

IF(CASENO.EQ.3) THEN
EYTH=0
SZTH=0
SXTH=APPSTR
EXTH=(SXTH/YOUNG)*(1+POISSON)*(1-POISSON)
EZTH=-EXTH*POISSON/(1-POISSON)
PTH=EXTH+EZTH
SYTH=PTH*YOUNG*POISSON/(1-2*POISSON)/(1+POISSON)
ENDIF

(STORED VAR SXTH IS :SXTH: WITH IMAT>100)
(STORED VAR SYTH IS :SYTH: WITH IMAT>100)
(STORED VAR SZTH IS :SZTH: WITH IMAT>100)
(STORED VAR EXTH IS :EXTH: WITH IMAT>100)
(STORED VAR EYTH IS :EYTH: WITH IMAT>100)
(STORED VAR EZTH IS :EZTH: WITH IMAT>100)

PTH=EXTH+EYTH+EZTH
(STORED VAR PTH IS :PTH:)

SPEDAT(RLXFAC,RLXU1D,R,0.1)
IF(CASENO.EQ.2) THEN
SPEDAT(BOUNDARY,YCONST,R,1.E20)  ! prevent y displacement
SPEDAT(BOUNDARY,ZCONST,R,1.E20)  ! prevent z displacement
ENDIF
IF(CASENO.EQ.3) THEN
SPEDAT(BOUNDARY,YCONST,R,1.E20)  ! prevent y displacement
ENDIF
STOP
```