###############################################
#
# Sub Routines for Truss Designer (FINK TRUSS MATRIX)
#
###############################################
########################
#
# Rigid Peak Joint
#
########################
sub Matrix {
##############################
#
# Overhang Loading and Graphs
#
##############################
if($Overhang > 0)
{
$Moment_overhang = ($Tctl_pli*$Overhang*$Overhang)/2;
$Moment_overhang_out = sprintf("%.1f", $Moment_overhang);
$Lgtoverhang = $Overhang/(cos($Phi));
$coefaover = -1*($Tctl_pli/2) * cos($Phi) * cos($Phi);
$coefaoverv = -1*($Tctl_pli) * cos($Phi) * cos($Phi);
$coefaovera = $Tctl_pli * sin($Phi) * cos($Phi);
$coefaover_out = sprintf("%.1f", $coefaover);
$coefaoverv_out = sprintf("%.1f", $coefaoverv);
$coefaovera_out = sprintf("%.1f", $coefaovera);
@momentsoverlist = ();
@xoverlist = ();
$Y_axisover = "";
$X_axisover = "";
$Y_axisoverv = "";
$Y_axisovera = "";
$Eqn_momentover = 'Overhang: M(x) = ' . "$coefaover_out" . 'x^2';
$Eqn_shearover = 'Overhang: V(x) = ' . "$coefaoverv_out" . 'x';
$Eqn_axialover = 'Overhang: A(x) = ' . "$coefaovera_out" . 'x';
for ($xover = 0; $xover < $Lgtoverhang; $xover +=.5)
{
$Momentoverx = $coefaover * $xover**2;
$Shearoverx = $coefaoverv * $xover;
$Axialoverx = $coefaovera * $xover;
push (@momentsoverlist, $Momentoverx);
push (@xoverlist, $xover);
$Y_axisover .= "$Momentoverx,";
$Y_axisoverv .= "$Shearoverx,";
$Y_axisovera .= "$Axialoverx,";
$X_axisover .= "\"$xover\",";
}
# Add point at panel point
$xover = $Lgtoverhang;
$Momentoverx = $coefaover * $xover**2;
$Shearoverx = $coefaoverv * $xover;
$Axialoverx = $coefaovera * $xover;
push (@momentsoverlist, $Momentoverx);
push (@xoverlist, $xover);
$Maxm_over_out = sprintf("%.1f", $Momentoverx);
$Maxv_over_out = sprintf("%.1f", $Shearoverx);
$Maxa_over_out = sprintf("%.1f", $Axialoverx);
$Y_axisover .= "$Momentoverx";
$Y_axisoverv .= "$Shearoverx";
$Y_axisovera .= "$Axialoverx";
$X_axisover .= "\"$xover\"";
}
else
{
$Moment_overhang = 0;
$Overhang_graphs_html = "";
}
####################################
#
# DISTRIBUTED LOADS MATRIX ANALYSIS
#
####################################
############################
#
# Known External Loads (Qk)
#
############################
$Shear1 = $Shear4 = $Tctl_pli*$L12*.5;
$Shear2 = $Shear3 = $Tctl_pli*$Ltcp*.5;
$Moment1 = $Moment4 = ($Tctl_pli*$L12*$L12)/12;
$Moment2 = $Moment3 = ($Tctl_pli*$Ltcp*$Ltcp)/12;
$Shear5 = $Shear7 = $Bctl_pli*$L17*.5;
$Shear6 = $Bctl_pli*$Lbcp*.5;
$Moment5 = $Moment7 = ($Bctl_pli*$L17*$L17)/12;
$Moment6 = ($Bctl_pli*$Lbcp*$Lbcp)/12;
$Moment1_neg = $Moment4_neg = -1*$Moment1;
$Moment2_neg = $Moment3_neg = -1*$Moment2;
$Moment5_neg = $Moment7_neg = -1*$Moment5;
$Moment6_neg = -1*$Moment6;
$Q1 = 0;
$Q2 = -1*($Shear1 + $Shear2);
$Q3 = $Moment1 - $Moment2;
$Q4 = 0;
$Q5 = -1*($Shear2 + $Shear3);
$Q6 = $Moment2 - $Moment3;
$Q7 = 0;
$Q8 = -1*($Shear3 + $Shear4);
$Q9 = $Moment3 - $Moment4;
$Q10 = 0;
$Q11 = -1*($Shear5 + $Shear6);
$Q12 = $Moment6 - $Moment5;
$Q13 = 0;
$Q14 = -1*($Shear6 + $Shear7);
$Q15 = $Moment7 - $Moment6;
$Q16 = 0;
$Q17 = ($Moment4 + $Moment5) - $Moment_overhang;
$Q18 = -1*($Moment1 + $Moment7) + $Moment_overhang;
$Qk_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $Q1 ]
[ $Q2 ]
[ $Q3 ]
[ $Q4 ]
[ $Q5 ]
[ $Q6 ]
[ $Q7 ]
[ $Q8 ]
[ $Q9 ]
[ $Q10 ]
[ $Q11 ]
[ $Q12 ]
[ $Q13 ]
[ $Q14 ]
[ $Q15 ]
[ $Q16 ]
[ $Q17 ]
[ $Q18 ]
MATRIX
$Qk_matrix_out = sprintf("%s", $Qk_matrix);
#################################
#
# Superimposed Loading TC and BC
#
#################################
$q1super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear1 ]
[ $Moment1 ]
[ 0 ]
[ $Shear1 ]
[ $Moment1_neg ]
MATRIX
$q2super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear2 ]
[ $Moment2 ]
[ 0 ]
[ $Shear2 ]
[ $Moment2_neg ]
MATRIX
###################################
#
# Corrected Superposition Matrices
#
###################################
$Shear1new = $Tctl_pli*$L12*.5*cos($Phi);
$Axial1new = $Tctl_pli*$L12*.5*sin($Phi);
$Moment1new = $Moment1;
$Moment1_negnew = $Moment1_neg;
$Shear2new = $Tctl_pli*$Ltcp*.5*cos($Phi);
$Axial2new = $Tctl_pli*$Ltcp*.5*sin($Phi);
$Moment2new = $Moment2;
$Moment2_negnew = $Moment2_neg;
$q1super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $Axial1new ]
[ $Shear1new ]
[ $Moment1new ]
[ $Axial1new ]
[ $Shear1new ]
[ $Moment1_negnew ]
MATRIX
$q2super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $Axial2new ]
[ $Shear2new ]
[ $Moment2new ]
[ $Axial2new ]
[ $Shear2new ]
[ $Moment2_negnew ]
MATRIX
###################################
$q3super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear3 ]
[ $Moment3 ]
[ 0 ]
[ $Shear3 ]
[ $Moment3_neg ]
MATRIX
$q4super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear4 ]
[ $Moment4 ]
[ 0 ]
[ $Shear4 ]
[ $Moment4_neg ]
MATRIX
$q5super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear5 ]
[ $Moment5 ]
[ 0 ]
[ $Shear5 ]
[ $Moment5_neg ]
MATRIX
$q6super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear6 ]
[ $Moment6 ]
[ 0 ]
[ $Shear6 ]
[ $Moment6_neg ]
MATRIX
$q7super_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ $Shear7 ]
[ $Moment7 ]
[ 0 ]
[ $Shear7 ]
[ $Moment7_neg ]
MATRIX
###########################
#
# Known Displacements (Dk)
#
###########################
$Dk_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ 0 ]
[ 0 ]
[ 0 ]
MATRIX
$Dk_matrix_out = sprintf("%s", $Dk_matrix);
$Matrix_email_output2 = qq{
Qk =
$Qk_matrix_out
Dk =
$Dk_matrix_out
};
###########################################
#
# Structure Stiffness Matrices for Members
#
###########################################
%k1map = (1 => 20, 2 => 21, 3 => 18, 4 => 1, 5 => 2, 6 => 3);
%k2map = (1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6);
%k3map = (1 => 4, 2 => 5, 3 => 6, 4 => 7, 5 => 8, 6 => 9);
%k4map = (1 => 7, 2 => 8, 3 => 9, 4 => 16, 5 => 19, 6 => 17);
%k5map = (1 => 10, 2 => 11, 3 => 12, 4 => 16, 5 => 19, 6 => 17);
%k6map = (1 => 13, 2 => 14, 3 => 15, 4 => 10, 5 => 11, 6 => 12);
%k7map = (1 => 20, 2 => 21, 3 => 18, 4 => 13, 5 => 14, 6 => 15);
%k8map = (1 => 13, 2 => 14, 3 => 15, 4 => 1, 5 => 2, 6 => 3);
%k9map = (1 => 13, 2 => 14, 3 => 15, 4 => 4, 5 => 5, 6 => 6);
%k10map = (1 => 10, 2 => 11, 3 => 12, 4 => 4, 5 => 5, 6 => 6);
%k11map = (1 => 10, 2 => 11, 3 => 12, 4 => 7, 5 => 8, 6 => 9);
%Thetax = (1 => $Phi,
2 => $Phi,
3 => -$Phi,
4 => -$Phi,
5 => 0,
6 => 0,
7 => 0,
8 => 3.14159265358 - $Alpha,
9 => $Beta,
10 => 3.14159265358 - $Beta,
11 => $Alpha);
%Area_hash = (1 => $A12,
2 => $A23,
3 => $A34,
4 => $A45,
5 => $A56,
6 => $A67,
7 => $A17,
8 => $A27,
9 => $A37,
10 => $A36,
11 => $A46);
%Inertia_hash = (1 => $Ix12,
2 => $Ix23,
3 => $Ix34,
4 => $Ix45,
5 => $Ix56,
6 => $Ix67,
7 => $Ix17,
8 => $Ix27,
9 => $Ix37,
10 => $Ix36,
11 => $Ix46);
%Length_hash = (1 => $Lgt12,
2 => $Lgt23,
3 => $Lgt34,
4 => $Lgt45,
5 => $Lgt56,
6 => $Lgt67,
7 => $Lgt17,
8 => $Lgt27,
9 => $Lgt37,
10 => $Lgt36,
11 => $Lgt46);
if (($E12) && ($E17) && ($E27) && ($E37))
{
%E_hash = (1 => $E12,
2 => $E12,
3 => $E12,
4 => $E12,
5 => $E17,
6 => $E17,
7 => $E17,
8 => $E27,
9 => $E37,
10 => $E37,
11 => $E27);
}
else
{
%E_hash = (1 => 1500000,
2 => 1500000,
3 => 1500000,
4 => 1500000,
5 => 1500000,
6 => 1500000,
7 => 1500000,
8 => 1500000,
9 => 1500000,
10 => 1500000,
11 => 1500000);
}
%Lambdax = ();
%Lambday = ();
%T_matrix_hash = ();
%TT_matrix_hash = ();
%kprime_matrix_hash = ();
%k_matrix_hash = ();
%k_assembly_matrix_hash = ();
$K_matrix = new Math::MatrixReal(21,21);
for ($Membernum = 1; $Membernum <= 11; $Membernum +=1)
{
$lmdx = $Lambdax{"$Membernum"} = cos($Thetax{"$Membernum"});
$lmdy = $Lambday{"$Membernum"} = sin($Thetax{"$Membernum"});
$lmdy_neg = $lmdy * -1;
#########################################
#
# Displacement Transformation Matrix (T)
#
#########################################
$T_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $lmdx $lmdy 0 0 0 0 ]
[ $lmdy_neg $lmdx 0 0 0 0 ]
[ 0 0 1 0 0 0 ]
[ 0 0 0 $lmdx $lmdy 0 ]
[ 0 0 0 $lmdy_neg $lmdx 0 ]
[ 0 0 0 0 0 1 ]
MATRIX
$T_matrix_out = sprintf("%s", $T_matrix);
$T_matrix_hash{"$Membernum"} = $T_matrix;
$Matrix_email_output2 .= qq{
T$Membernum =
$T_matrix_out
};
#####################################
#
# Force Transformation Matrix (TT)
#
#####################################
$TT_matrix = new Math::MatrixReal(6,6);
$TT_matrix->transpose($T_matrix);
$TT_matrix_out = sprintf("%s", $TT_matrix);
$TT_matrix_hash{"$Membernum"} = $TT_matrix;
$Matrix_email_output2 .= qq{
TT$Membernum =
$TT_matrix_out
};
#####################################
#
# Member Stiffness Matrix (k')
#
#####################################
$AE_L = ($Area_hash{"$Membernum"} * $E_hash{"$Membernum"})/$Length_hash{"$Membernum"};
$EI12_LLL = (12 * $Inertia_hash{"$Membernum"} * $E_hash{"$Membernum"})/($Length_hash{"$Membernum"})**3;
$EI6_LL = (6 * $Inertia_hash{"$Membernum"} * $E_hash{"$Membernum"})/($Length_hash{"$Membernum"})**2;
$EI4_L = (4 * $Inertia_hash{"$Membernum"} * $E_hash{"$Membernum"})/($Length_hash{"$Membernum"});
$EI2_L = (2 * $Inertia_hash{"$Membernum"} * $E_hash{"$Membernum"})/($Length_hash{"$Membernum"});
$AE_L_neg = $AE_L * -1;
$EI12_LLL_neg = $EI12_LLL * -1;
$EI6_LL_neg = $EI6_LL * -1;
if ($Membernum >= 8)
{
$kprime_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $AE_L 0 0 $AE_L_neg 0 0 ]
[ 0 0 0 0 0 0 ]
[ 0 0 0 0 0 0 ]
[ $AE_L_neg 0 0 $AE_L 0 0 ]
[ 0 0 0 0 0 0 ]
[ 0 0 0 0 0 0 ]
MATRIX
}
else
{
$kprime_matrix = Math::MatrixReal->new_from_string(<<"MATRIX");
[ $AE_L 0 0 $AE_L_neg 0 0 ]
[ 0 $EI12_LLL $EI6_LL 0 $EI12_LLL_neg $EI6_LL ]
[ 0 $EI6_LL $EI4_L 0 $EI6_LL_neg $EI2_L ]
[ $AE_L_neg 0 0 $AE_L 0 0 ]
[ 0 $EI12_LLL_neg $EI6_LL_neg 0 $EI12_LLL $EI6_LL_neg ]
[ 0 $EI6_LL $EI2_L 0 $EI6_LL_neg $EI4_L ]
MATRIX
}
$kprime_matrix_out = sprintf("%s", $kprime_matrix);
$kprime_matrix_hash{"$Membernum"} = $kprime_matrix;
$Matrix_email_output2 .= qq{
k'$Membernum =
$kprime_matrix_out
};
#####################################
#
# Global Member Stiffness Matrix (k)
#
#####################################
$k_matrix = ($TT_matrix * $kprime_matrix) * $T_matrix;
$k_matrix_out = sprintf("%s", $k_matrix);
$k_matrix_hash{"$Membernum"} = $k_matrix;
$Matrix_email_output2 .= qq{
k$Membernum =
$k_matrix_out
};
#######################################################
#
# Global Member Stiffness Matrix (Assembly) (k padded)
#
#######################################################
$kmap_name = 'k'."$Membernum".'map';
%kmap = %{$kmap_name};
$k_assembly_matrix = new Math::MatrixReal(21,21);
for ($ith = 1; $ith <= 6; $ith +=1)
{
$rowmap = $kmap{"$ith"};
for ($jth = 1; $jth <= 6; $jth +=1)
{
$colmap = $kmap{"$jth"};
$kvalue = $k_matrix->element($ith,$jth);
$k_assembly_matrix->assign($rowmap,$colmap,$kvalue);
}
}
$k_assembly_matrix_out = sprintf("%s", $k_assembly_matrix);
$k_assembly_matrix_hash{"$Membernum"} = $k_assembly_matrix;
$Matrix_email_output2 .= qq{
k$Membernum Assembly =
$k_assembly_matrix_out
};
################################
#
# Structure Stiffness Matrix (K)
#
################################
$K_matrix = $K_matrix + $k_assembly_matrix;
}
$K_matrix_out = sprintf("%s", $K_matrix);
$Matrix_email_output2 .= qq{
K Structure Stiffness Matrix =
$K_matrix_out
};
#############################
#
# K11 Matrix (K11)
#
#############################
$K11_matrix = new Math::MatrixReal(18,18);
for ($ith = 1; $ith <= 18; $ith +=1)
{
for ($jth = 1; $jth <= 18; $jth +=1)
{
$K11value = $K_matrix->element($ith,$jth);
$K11_matrix->assign($ith,$jth,$K11value);
}
}
$K11_matrix_out = sprintf("%s", $K11_matrix);
#print qq{<br>$K11_matrix_out};
$Matrix_email_output2 .= qq{
K11 Matrix =
$K11_matrix_out
};
#############################
#
# K21 Matrix (K21)
#
#############################
$K21_matrix = new Math::MatrixReal(3,18);
for ($ith = 19; $ith <= 21; $ith +=1)
{
$ith21 = $ith - 18;
for ($jth = 1; $jth <= 18; $jth +=1)
{
$K21value = $K_matrix->element($ith,$jth);
$K21_matrix->assign($ith21,$jth,$K21value);
}
}
$K21_matrix_out = sprintf("%s", $K21_matrix);
$Matrix_email_output2 .= qq{
K21 Matrix =
$K21_matrix_out
};
#############################
#
# K11INV Matrix (K11 Inverse)
#
#############################
$K11INV_matrix = $K11_matrix->decompose_LR->invert_LR;
$K11INV_matrix_out = sprintf("%s", $K11INV_matrix);
$I_matrix = $K11_matrix * $K11INV_matrix;
$I_matrix_out = sprintf("%s", $I_matrix);
$Matrix_email_output2 .= qq{
K11 Inverse Matrix =
$K11INV_matrix_out
Indentity Matrix Check =
$I_matrix_out
};
#############################
#
# Du Matrix (Du)
#
#############################
$Du_matrix = $K11INV_matrix * $Qk_matrix;
$Du_matrix_out = sprintf("%s", $Du_matrix);
$Matrix_email_output2 .= qq{
Du Matrix =
$Du_matrix_out
};
#############################
#
# Qu Matrix (Qu)
#
#############################
$Qu_matrix = $K21_matrix * $Du_matrix;
$Qu_matrix_out = sprintf("%s", $Qu_matrix);
$Matrix_email_output2 .= qq{
Qu Matrix =
$Qu_matrix_out
};
####################################
#
# Displacement Matrix (D = Du + Dk)
#
####################################
$DuT_matrix = new Math::MatrixReal(1,18);
$DuT_matrix->transpose($Du_matrix);
$DkT_matrix = new Math::MatrixReal(1,3);
$DkT_matrix->transpose($Dk_matrix);
$DT_matrix = $DuT_matrix . $DkT_matrix;
$D_matrix = new Math::MatrixReal(21,1);
$D_matrix->transpose($DT_matrix);
$D_matrix_out = sprintf("%s", $D_matrix);
$Matrix_email_output2 .= qq{
D Matrix =
$D_matrix_out
};
####################################
#
# Internal Loading of Members (q)
#
####################################
%D_member_matrix_hash = ();
%q_matrix_hash = ();
%qmod_matrix_hash = ();
for ($Membernum = 1; $Membernum <= 11; $Membernum +=1)
{
$kmap_name = 'k'."$Membernum".'map';
%kmap = %{$kmap_name};
$D_member_matrix = new Math::MatrixReal(6,1);
for ($ith = 1; $ith <= 6; $ith +=1)
{
$rowmap = $kmap{"$ith"};
$kvalue = $D_matrix->element($rowmap,1);
$D_member_matrix->assign($ith,1,$kvalue);
}
$D_member_matrix_out = sprintf("%s", $D_member_matrix);
$D_member_matrix_hash{"$Membernum"} = $D_member_matrix;
$q_matrix = ($kprime_matrix_hash{"$Membernum"} * $T_matrix_hash{"$Membernum"}) * $D_member_matrix;
$q_matrix_out = sprintf("%s", $q_matrix);
$q_matrix_hash{"$Membernum"} = $q_matrix;
if ($Membernum =~ /^[1234567]$/)
{
# $q1super_matrix
$super_matrix_name = 'q'."$Membernum".'super_matrix';
$qsuper_matrix = ${$super_matrix_name};
$qmod_matrix = $qsuper_matrix + $q_matrix;
$qmod_matrix_out = sprintf("%s", $qmod_matrix);
$qmod_matrix_hash{"$Membernum"} = $qmod_matrix;
$Matrix_email_output_full .= qq{
D$Membernum =
$D_member_matrix_out
q$Membernum =
$q_matrix_out
q$Membernum (mod) =
$qmod_matrix_out
};
$Matrix_email_output .= qq{
q$Membernum (mod) =
$qmod_matrix_out
};
}
else
{
$Matrix_email_output_full .= qq{
D$Membernum =
$D_member_matrix_out
q$Membernum =
$q_matrix_out
};
$Matrix_email_output .= qq{
q$Membernum =
$q_matrix_out
};
}
}
# TEST AND DEBUG CODE
#$Matrix_email_output .= join("\n", %Thetax);
#$Matrix_email_output .= join("\n", %Lambdax);
#$Matrix_email_output .= join("\n", %Lambday);
$Matrix_email_output .= join("\n", %E_hash);