โปรแกรมคอมพิวเตอร์เบื้องต้นสำหรับวิเคราะห์โครงข้อหมุน โดยใช้วิธีรวมสติฟเนสโดยตรง อ่าน 5,053

โปรแกรมคอมพิวเตอร์เบื้องต้นสำหรับวิเคราะห์โครงข้อหมุน โดยใช้วิธีรวมสติฟเนสโดยตรง  วิเคราะห์โครงสร้าง

Basic Computer Program for Truss Analysis by Direct Stiffness Method

โดย อ.สรกานต์  ศรีตองอ่อน


Program TrussAnalysis;

 

 

Uses Crt;

 

 

Const

 

 

  MaxNode = 50;

 

 

  MaxMat  = 5;

 

 

  MaxMem  = 25;

 

 

  Head    = 1;

 

 

  Tail    = 2;

 

 

  MaxSup  = 15;

 

 

  MaxLoad = 2*MaxNode;

 

 

Var

 

 

  NumN  : Integer; {Number of Nodes}

 

 

  NumEq : Integer;

 

 

  NumM  : Integer; {Number of Members}

 

 

  NMat  : Integer; {Number of Materials}

 

 

  NSup  : Integer; {Number of Support Nodes}

 

 

  NumLN : Integer; {Number of Loaded Nodes}

 

 

  {Input Variables}

 

 

  X, Y  : Array[1..MaxNode] of Real;

 

 

  Elas  : Array[1..MaxMat] of Real;

 

 

  NodeM : Array[1..MaxMem,Head..Tail] of Integer;

 

 

  Area  : Array[1..MaxMem] of Real;

 

 

  TypeM : Array[1..MaxMem] of Byte;

 

 

  NRx, NRy : Array[1..MaxSup] of Byte;

 

 

  P     : Array[1..MaxLoad] of Real;

 

 

  {Compute Variables}

 

 

  Rx, Ry : Array[1..MaxNode] of Real;

 

 

  Length, Cx, Cy : Array[1..MaxMem] of Real;

 

 

  Kgbl   : Array[1..MaxLoad,1..MaxLoad] of Real;

 

 

  D      : Array[1..MaxLoad] of Real;

 

 

  S      : Array[1..MaxMem] of Real;

 

 

 

 

 

{**************** Input **************}

 

 

Procedure ControlData;

 

 

{Input Control Data}

 

 

Begin

 

 

  ClrScr;

 

 

  Write('Number of Nodes : '); ReadLn(NumN);

 

 

  NumEq := 2*NumN;

 

 

  Write('Number of Members : '); ReadLn(NumM);

 

 

  Write('Number of Materials : '); ReadLn(NMat);

 

 

  Write('Number of Support Nodes : '); ReadLn(NSup);

 

 

  Write('Number of Loaded Nodes : '); ReadLn(NumLN);

 

 

End;

 

 

 

 

 

Procedure NodeCoordinates;

 

 

{Input Node Coordinates}

 

 

Var I : Byte;

 

 

Begin

 

 

  For I := 1 to NumN Do

 

 

  Begin

 

 

    ClrScr;

 

 

    WriteLn('Node ',I);

 

 

    Write('X = '); ReadLn(X[I]);

 

 

    Write('Y = '); ReadLn(Y[I]);

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure Material;

 

 

{Input Material Data}

 

 

Var I : Byte;

 

 

Begin

 

 

  For I := 1 to NMat Do

 

 

  Begin

 

 

    ClrScr;

 

 

    WriteLn('Material Number ',I);

 

 

    Write('Modulas of Elasticity = ');

 

 

    ReadLn(Elas[I]);

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure Member;

 

 

{Input Member Data}

 

 

Var I : Byte;

 

 

Begin

 

 

  For I := 1 to NumM Do

 

 

  Begin

 

 

    ClrScr;

 

 

    WriteLn('Member ',I);

 

 

    Write('Head Node = '); ReadLn(NodeM[I,Head]);

 

 

    Write('Tail Node = '); ReadLn(NodeM[I,Tail]);

 

 

    Write('Area = '); ReadLn(Area[I]);

 

 

    If NMat = 1 Then

 

 

      TypeM[I] := 1

 

 

    Else

 

 

    Begin

 

 

      Write('Material Number = '); ReadLn(TypeM[I]);

 

 

    End;

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure SupRestraints;

 

 

{Input Support Restraints}

 

 

Var

 

 

  I, J : Byte;

 

 

  Ch   : Char;

 

 

Begin

 

 

  For I := 1 to NSup Do

 

 

  Begin

 

 

    ClrScr;

 

 

    Write('Support Node Number : '); ReadLn(J);

 

 

    Write('Roller or Hinge (R or H) : ');

 

 

    ReadLn(Ch);

 

 

    If Upcase(Ch) = 'R' Then

 

 

    Begin

 

 

      NRx[J] := 0; NRy[J] := 1;

 

 

    End Else

 

 

    If Upcase(Ch) = 'H' Then

 

 

    Begin

 

 

      NRx[J] := 1; NRy[J] := 1;

 

 

    End;

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure NodeLoads;

 

 

{Input Node Loads}

 

 

Var

 

 

  I, J : Integer;

 

 

Begin

 

 

  For I := 1 to NumEq Do P[I] := 0;

 

 

  For I := 1 to NumLN Do

 

 

  Begin

 

 

    ClrScr;

 

 

    Write('Load Node Number : '); ReadLn(J);

 

 

    Write('X force = '); ReadLn(P[2*J-1]);

 

 

    Write('Y force = '); ReadLn(P[2*J]);

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure InputData;

 

 

Begin

 

 

  ControlData;

 

 

  NodeCoordinates;

 

 

  Material;

 

 

  Member;

 

 

  SupRestraints;

 

 

  NodeLoads;

 

 

End;

 

 

{**************** Input **************}

 

 

 

 

 

{*************** Compute *************}

 

 

Procedure InitialReaction;

 

 

{Initialize Reaction Array}

 

 

Var I : Integer;

 

 

Begin

 

 

  For I := 1 to NumN Do

 

 

  Begin

 

 

    If (NRx[I] = 1) And (P[2*I-1] <> 0) Then

 

 

      Rx[I] := -P[2*I-1]

 

 

    Else

 

 

      Rx[I] := 0;

 

 

    If (NRy[I] = 1) And (P[2*I] <> 0) Then

 

 

      Ry[I] := -P[2*I]

 

 

    Else

 

 

      Ry[I] := 0;

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure MemLenghtsandDirectCos;

 

 

{Compute Member Lenghts and Direction Cosines}

 

 

Var

 

 

  I      : Integer;

 

 

  J1, J2 : Integer;

 

 

  XL, YL : Real;

 

 

Begin

 

 

  For I := 1 to NumM Do

 

 

  Begin

 

 

    J1 := NodeM[I,Head];

 

 

    J2 := NodeM[I,Tail];

 

 

    XL := X[J2]-X[J1];

 

 

    YL := Y[J2]-Y[J1];

 

 

    Length[I] := Sqrt(Sqr(XL)+Sqr(YL));

 

 

    Cx[I] := XL/Length[I];

 

 

    Cy[I] := YL/Length[I];

 

 

  End;

 

 

End;

 

 

 

 

 

Procedure UnresGlobal;

 

 

{Generate Unrestrained Global Stiffness Matrix}

 

 

Var

 

 

  I, J   : Integer;

 

 

  J1, J2 : Integer;

 

 

  Aeol, XX, YY, XY : Real;

 

 

  J12M1, J12, J22M1, J22 : Integer;

 

 

Begin

 

 

  For I := 1 to NumEq Do

 

 

  Begin

 

 

    For J := 1 to NumEq Do

 

 

      Kgbl[I,J] := 0;

 

 

  End;

 

 

  For I := 1 to NumM Do

 

 

  Begin

 

 

    J1 := NodeM[I,Head];

 

 

    J2 := NodeM[I,Tail];

 

 

    J := TypeM[I];

 

 

    AEoL := Area[I]*Elas[J]/Length[I];

 

 

    XX := AEoL*Sqr(Cx[I]);

 

 

    YY := AEoL*Sqr(Cy[I]);

 

 

    XY := AEoL*Cx[I]*Cy[I];

 

 

    J12M1 := 2*J1-1;

 

 

    J12 := 2*J1;

 

 

    J22M1 := 2*J2-1;

 

 

    J22 := 2*J2;

 

 

    Kgbl[J12M1,J12M1] := Kgbl[J12M1,J12M1]+XX;

 

 

    Kgbl[J12M1,J12]   := Kgbl[J12M1,J12]+XY;

 

 

    Kgbl[J12M1,J22M1] := Kgbl[J12M1,J22M1]-XX;

 

 

    Kgbl[J12M1,J22]   := Kgbl[J12M1,J22]-XY;

 

 

    Kgbl[J12,J12M1]   := Kgbl[J12,J12M1]+XY;

 

 

    Kgbl[J12,J12]     := Kgbl[J12,J12]+YY;

 

 

    Kgbl[J12,J22M1]   := Kgbl[J12,J22M1]-XY;

 

 

    Kgbl[J12,J22]     := Kgbl[J12,J22]-YY;

 

 

    Kgbl[J22M1,J12M1] := Kgbl[J22M1,J12M1]-XX;

 

 

    Kgbl[J22M1,J12]   := Kgbl[J22M1,J12]-XY;

 

 

    Kgbl[J22M1,J22M1] := Kgbl[J22M1,J22M1]+XX;

 

 

    Kgbl[J22M1,J22]   := Kgbl[J22M1,J22]+XY;

 

 

    Kgbl[J22,J12M1]   := Kgbl[J22,J12M1]-XY;

 

 

    Kgbl[J22,J12]     := Kgbl[J22,J12]-YY;

 

 

    Kgbl[J22,J22M1]   := Kgbl[J22,J22M1]+XY;

 

 

    Kgbl[J22,J22]     := Kgbl[J22,J22]+YY;

 

 

  End;

 

 

End;

 

 

คะแนน:
ร่วมแสดงความคิดเห็น (Post Comment)