!***************************************************************
! propcalcu        / 2000-10-16 / Vertex Systems Oy            *
!***************************************************************
!
! Calulates cross section properties
!
DB_OPEN_FAIL$=GetPrompt("CANT_OPEN_DB")
PARAM_ERROR$="Can't get parameters of"
!
IdProp= 1
LidProp= 1
Lid= 2
IdPar= 2
Dir$= get("SECTPATH");
!
!
! Open Property Database
!
Path$= Dir$&"d_PROFDATA"
dbopen(IdProp) Path$,1
if dbvalid(IdProp) < 1 then
  dbclose(IdProp)
  message(DB_OPEN_FAIL$&Path$,0);
  exit
endif
!
! Open Parameters Database
!
Path$= Dir$&"d_PROFPAR"
dbopen(IdPar) Path$,1
if dbvalid(IdPar) < 1 then
  dbclose(IdProp)
  dbclose(IdPar)
  message(DB_OPEN_FAIL$&Path$,0);
  exit
endif
!
!
! Calculate properties
!
dbfind(LidProp) IdProp,0,""
Prop0= dblistnum(LidProp)
I= 1
loop Prop0
  RidProp= dblist(LidProp,I)
  Value$= dbgetf(IdProp,RidProp,"CODE")
  Where$= "where CODE = """&Value$&""""
  DBfind(Lid) IdPar,1,Where$
  Row0= dblistnum(Lid)
  if (Row0 == 1) then
	Rid= dblist(Lid,1)
	T= dbgetf(IdPar,Rid,"TYPE")
	H= dbgetf(IdPar,Rid,"HEIGHT")
	B= dbgetf(IdPar,Rid,"WIDTH")
	A= dbgetf(IdPar,Rid,"ANGLE")
 	!
	dbputf(IdProp) RidProp,"PUNIT","10"
	H= H/10
	B= B/10
	dblclose(Lid)
	!
	dbputf(IdProp) RidProp,"SHAPETYPE","RECTAN"
	!
	Val= B/2
	dbputf(IdProp) RidProp,"Z2",Val
	Val= Val*-1
	dbputf(IdProp) RidProp,"Z1",Val
	Val= H/2
	dbputf(IdProp) RidProp,"Y2",Val
	Val= Val*-1
	dbputf(IdProp) RidProp,"Y1",Val
	Val= B*H
	dbputf(IdProp) RidProp,"A",Val
	Val= B*H/1.09
	dbputf(IdProp) RidProp,"AY",Val
	dbputf(IdProp) RidProp,"AZ",Val
	Val= 2*(B+H)
	dbputf(IdProp) RidProp,"U",Val
	Val= B*H*H/8
	dbputf(IdProp) RidProp,"SZ",Val
	Val= H*B*B/8
	dbputf(IdProp) RidProp,"SY",Val
	R= H/B
	if (R == 1) then
  	Alfa= 0.141 
	Beta=	0.208
	endif
	if (R > 1.0 && R <= 1.5) then
	  Alfa= 0.141 + (R-1.0)/0.5*(0.196 - 0.141)
	  Beta= 0.208 + (R-1.0)/0.5*(0.321 - 0.208)
	endif
	if (R > 1.5 && R <= 2.0) then
	  Alfa= 0.196 + (R-1.5)/0.5*(0.229 - 0.196)
	  Beta= 0.231 + (R-1.5)/0.5*(0.246 - 0.231)
	endif
	if (R > 2.0 && R <= 2.5) then
	  Alfa= 0.229 + (R-2.0)/0.5*(0.249 - 0.229)
	  Beta= 0.246 + (R-2.0)/0.5*(0.258 - 0.246)
	endif
	if (R > 2.5 && R <= 3.0) then
	  Alfa= 0.249 + (R-2.5)/0.5*(0.263 - 0.249)
	  Beta= 0.258 + (R-2.5)/0.5*(0.267 - 0.258)
	endif
	if (R > 3.0 && R <= 4.0) then
	  Alfa= 0.263 + (R-3.0)/1.0*(0.281 - 0.263)
	  Beta= 0.267 + (R-3.0)/1.0*(0.282 - 0.267)
	endif
	if (R > 4.0 && R <= 6.0) then
	  Alfa= 0.281 + (R-4.0)/2.0*(0.299 - 0.281)
	  Beta= 0.282 + (R-4.0)/2.0*(0.299 - 0.281)
	endif
	if (R > 6.0 && R <= 8.0) then
	  Alfa= 0.299 + (R-6.0)/2.0*(0.307 - 0.299)
	  Beta= 0.299 + (R-6.0)/2.0*(0.307 - 0.299)
	endif
	if (R > 8.0 && R <= 10.0) then
	  Alfa= 0.307 + (R-8.0)/2.0*(0.313 - 0.307)
	  Beta= 0.307 + (R-8.0)/2.0*(0.313 - 0.307)
	endif
	if (R > 10) then
	  Alfa= 0.333
	  Beta= 0.333
	endif 
	Val= Alfa*H*pow(B,3)
	dbputf(IdProp) RidProp,"IV",Val
	Val= Beta*H*B*B
	dbputf(IdProp) RidProp,"WV",Val
	Val= B*pow(H,3)/12
	dbputf(IdProp) RidProp,"IZ",Val
	Val= H*pow(B,3)/12
	dbputf(IdProp) RidProp,"IY",Val
  else
 	dblclose(Lid)
	Mess$= PARAM_ERROR$&Value$
	message(Mess$,0);
	exitif 1
  endif
  I= I+1
endloop
!
dbclose(IdProp)
dbclose(IdPar)
!
