public NodePointLoad(AnalysisCase analysisCase, double fx, double fz, double my) : base(analysisCase) { FX = fx; FZ = fz; MY = my; }
/// <summary> /// Adds a new analysis case to the model. /// </summary> public AnalysisCase AddAnalysisCase(string name) { AnalysisCase a = new AnalysisCase(name); AnalysisCases.Add(a); return a; }
/// <summary> /// Calculates frame internal forces the given load case and global deformation vector. /// </summary> private void CalculateFrameInternalForces(AnalysisCase analysisCase, Vector <double> deformations) { analysisCase.FrameInternalForces.Clear(); foreach (Frame frame in Frames) { int i = frame.NodeI.Index; int j = frame.NodeJ.Index; Vector <double> globalDeformations = Vector <double> .Build.Dense(6, 0); globalDeformations[0] = deformations[i * 3 + 0]; globalDeformations[1] = deformations[i * 3 + 1]; globalDeformations[2] = deformations[i * 3 + 2]; globalDeformations[3] = deformations[j * 3 + 0]; globalDeformations[4] = deformations[j * 3 + 1]; globalDeformations[5] = deformations[j * 3 + 2]; Vector <double> localDeformations = frame.Transformation.Transpose().Inverse() * globalDeformations; Vector <double> internalForces = frame.LocalElementStiffness * localDeformations; double ni = internalForces[0]; double vi = internalForces[1]; double mi = -internalForces[2]; double nj = -internalForces[3]; double vj = -internalForces[4]; double mj = internalForces[5]; FrameInternalForce force = new FrameInternalForce(frame, ni, vi, mi, nj, vj, mj); analysisCase.FrameInternalForces.Add(force); } }
/// <summary> /// Adds a new analysis case to the model. /// </summary> public AnalysisCase AddAnalysisCase(string name) { AnalysisCase a = new AnalysisCase(name); AnalysisCases.Add(a); return(a); }
public FrameTrapezoidalLoad(AnalysisCase analysisCase, double fxi, double fzi, double fxj, double fzj) : base(analysisCase) { FXI = fxi; FZI = fzi; FXJ = fxj; FZJ = fzj; }
/// <summary> /// Calculates node deformations for the given load case and deformation vector. /// </summary> private void CalculateDeformations(AnalysisCase analysisCase, Vector <double> deformations) { analysisCase.NodeDeformations.Clear(); for (int i = 0; i < nodes.Count; i++) { int j = nodes[i].Index; NodeDeformation d = new NodeDeformation(nodes[i], deformations[j * 3], deformations[j * 3 + 1], deformations[j * 3 + 2]); analysisCase.NodeDeformations.Add(d); } }
public void SetCoefficient(double coefficient, AnalysisCase analysisCase) { if (acCoefficients.ContainsKey(analysisCase)) { acCoefficients[analysisCase] = coefficient; } else { acCoefficients.Add(analysisCase, coefficient); } }
/// <summary> /// Calculates support reactions for the given load case and deformation vector. /// </summary> private void CalculateReactions(AnalysisCase analysisCase, Vector <double> reactions) { analysisCase.Reactions.Clear(); for (int i = 0; i < nodes.Count; i++) { int j = nodes[i].Index; if (nodes[i].Restraints != DOF.Free) { Reaction r = new Reaction(nodes[i], reactions[j * 3], reactions[j * 3 + 1], reactions[j * 3 + 2]); analysisCase.Reactions.Add(r); } } }
/// <summary> /// Solves the system for the given load case. /// </summary> public void Run(AnalysisCase analysisCase) { AssignNodeIndices(); if (stiffnessMatrix == null) { BuildStiffnessMatrix(); } Vector <double> f = GetLoadVector(analysisCase); Vector <double> d = restrainedStiffnessMatrix.Solve(f); CalculateDeformations(analysisCase, d); Vector <double> r = stiffnessMatrix * d; CalculateReactions(analysisCase, r); CalculateFrameInternalForces(analysisCase, d); }
private void DrawDeformations(AnalysisCase analysisCase) { DrawDeformations(analysisCase.NodeDeformations); }
private void DrawReactions(AnalysisCase analysisCase) { DrawReactions(analysisCase.Reactions); }
/// <summary> /// Returns the load vector for the given load case. /// </summary> private Vector<double> GetLoadVector(AnalysisCase analysisCase) { Vector<double> p = Vector<double>.Build.Dense(nodes.Count * 3, 0); // Node loads foreach (Node node in nodes) { foreach (NodeLoad load in node.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is NodePointLoad) { // Applied point loads NodePointLoad pl = (NodePointLoad)load; int i = node.Index; p[i * 3 + 0] += pl.FX; p[i * 3 + 1] += pl.FZ; p[i * 3 + 2] += pl.MY; } } } // Frame loads foreach (Frame frame in Frames) { double l = frame.Length; int i = frame.NodeI.Index; int j = frame.NodeJ.Index; foreach (FrameLoad load in frame.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is FrameUniformLoad) { // Frame fixed-end reactions from frame uniform loads FrameUniformLoad pl = (FrameUniformLoad)load; double fx = pl.FX * l / 2.0; double fz = pl.FZ * l / 2.0; p[i * 3 + 0] += fx; p[i * 3 + 1] += fz; p[i * 3 + 2] += 0; // End moment p[j * 3 + 0] += fx; p[j * 3 + 1] += fz; p[j * 3 + 2] += 0; // End moment } else if (load is FrameTrapezoidalLoad) { // Frame fixed-end reactions from frame trapezoidal loads FrameTrapezoidalLoad pl = (FrameTrapezoidalLoad)load; double fx = (pl.FXI + pl.FXJ) / 2.0 * l / 2.0; double fz = (pl.FZI + pl.FZJ) / 2.0 * l / 2.0; p[i * 3 + 0] += fx; p[i * 3 + 1] += fz; p[i * 3 + 2] += 0; // End moment p[j * 3 + 0] += fx; p[j * 3 + 1] += fz; p[j * 3 + 2] += 0; // End moment } } } // Set restrained node coefficients to 0 foreach (Node n in nodes) { if ((n.Restraints & DOF.UX) != DOF.Free) p[n.Index * 3 + 0] = 0; if ((n.Restraints & DOF.UZ) != DOF.Free) p[n.Index * 3 + 1] = 0; if ((n.Restraints & DOF.RY) != DOF.Free) p[n.Index * 3 + 2] = 0; } return p; }
public FrameLoad(AnalysisCase analysisCase) { AnalysisCase = analysisCase; }
private void DrawFrameShearForces(AnalysisCase analysisCase) { DrawFrameShearForces(analysisCase.FrameInternalForces); }
/// <summary> /// Calculates frame internal forces the given load case and global deformation vector. /// </summary> private void CalculateFrameInternalForces(AnalysisCase analysisCase, Vector<double> deformations) { analysisCase.FrameInternalForces.Clear(); foreach (Frame frame in Frames) { int i = frame.NodeI.Index; int j = frame.NodeJ.Index; Vector<double> globalDeformations = Vector<double>.Build.Dense(6, 0); globalDeformations[0] = deformations[i * 3 + 0]; globalDeformations[1] = deformations[i * 3 + 1]; globalDeformations[2] = deformations[i * 3 + 2]; globalDeformations[3] = deformations[j * 3 + 0]; globalDeformations[4] = deformations[j * 3 + 1]; globalDeformations[5] = deformations[j * 3 + 2]; Vector<double> localDeformations = frame.Transformation.Transpose().Inverse() * globalDeformations; Vector<double> internalForces = frame.LocalElementStiffness * localDeformations; double ni = internalForces[0]; double vi = internalForces[1]; double mi = -internalForces[2]; double nj = -internalForces[3]; double vj = -internalForces[4]; double mj = internalForces[5]; FrameInternalForce force = new FrameInternalForce(frame, ni, vi, mi, nj, vj, mj); analysisCase.FrameInternalForces.Add(force); } }
/// <summary> /// Adds a new frame trapezoidal load. /// </summary> public void AddTrapezoidalLoad(AnalysisCase analysisCase, double fxi, double fzi, double fxj, double fzj) { Loads.Add(new FrameTrapezoidalLoad(analysisCase, fxi, fzi, fxj, fzj)); }
/// <summary> /// Adds a new node point load. /// </summary> public void AddNodePointLoad(AnalysisCase analysisCase, Node node, double fx, double fz, double my) { node.AddPointLoad(analysisCase, fx, fz, my); }
/// <summary> /// Adds frame self weight load. /// </summary> public void AddFrameSelfWeight(AnalysisCase analysisCase, Frame frame) { frame.AddUniformLoad(analysisCase, 0, -frame.WeightPerLength); }
/// <summary> /// Adds a new frame trapezoidal load. /// </summary> public void AddFrameTrapezoidalLoad(AnalysisCase analysisCase, Frame frame, double fxi, double fzi, double fxj, double fzj) { frame.AddTrapezoidalLoad(analysisCase, fxi, fzi, fxj, fzj); }
private void DrawFrameLoads(AnalysisCase analysisCase) { float maxLoadSize = 10 * DimensionOffset; float textOffset = 0.5f * TextSize; float maxLoad = 0; foreach (Frame f in mCurrentSection.AnalysisModel.Frames) { foreach (FrameLoad load in f.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is FrameUniformLoad) { FrameUniformLoad uniformLoad = load as FrameUniformLoad; maxLoad = (float)Math.Max(maxLoad, Math.Max(Math.Abs(uniformLoad.FX), Math.Abs(uniformLoad.FZ))); } if (load is FrameTrapezoidalLoad) { FrameTrapezoidalLoad trapezoidalLoad = load as FrameTrapezoidalLoad; maxLoad = (float)Math.Max(maxLoad, Math.Max(Math.Abs(trapezoidalLoad.FXI), Math.Abs(trapezoidalLoad.FZI))); maxLoad = (float)Math.Max(maxLoad, Math.Max(Math.Abs(trapezoidalLoad.FXJ), Math.Abs(trapezoidalLoad.FZJ))); } } } foreach (Frame f in mCurrentSection.AnalysisModel.Frames) { float x1 = (float)f.NodeI.X; float y1 = (float)f.NodeI.Z; float x2 = (float)f.NodeJ.X; float y2 = (float)f.NodeJ.Z; float angle = (float)f.Angle * 180 / (float)Math.PI + 90; foreach (FrameLoad load in f.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is FrameUniformLoad) { FrameUniformLoad uniformLoad = load as FrameUniformLoad; float loadx1 = x1 - (float)uniformLoad.FX * maxLoadSize / maxLoad; float loady1 = y1 - (float)uniformLoad.FZ * maxLoadSize / maxLoad; float loadx2 = x2 - (float)uniformLoad.FX * maxLoadSize / maxLoad; float loady2 = y2 - (float)uniformLoad.FZ * maxLoadSize / maxLoad; SimpleCAD.Polygon poly = new SimpleCAD.Polygon(new PointF[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(loadx2, loady2), new PointF(loadx1, loady1) }); poly.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); poly.FillStyle = new SimpleCAD.FillStyle(ShadingColor); Model.Add(poly); SimpleCAD.Text text = new SimpleCAD.Text(loadx1, loady1, uniformLoad.FX.ToString("0.0") + ", " + uniformLoad.FZ.ToString("0.0"), TextSize); text.HorizontalAlignment = StringAlignment.Near; text.VerticalAlignment = StringAlignment.Center; text.Rotation = angle; text.FontFamily = Font.Name; text.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); Model.Add(text); } if (load is FrameTrapezoidalLoad) { FrameTrapezoidalLoad trapezoidalLoad = load as FrameTrapezoidalLoad; float loadx1 = x1 - (float)trapezoidalLoad.FXI * maxLoadSize / maxLoad; float loady1 = y1 - (float)trapezoidalLoad.FZI * maxLoadSize / maxLoad; float loadx2 = x2 - (float)trapezoidalLoad.FXJ * maxLoadSize / maxLoad; float loady2 = y2 - (float)trapezoidalLoad.FZJ * maxLoadSize / maxLoad; SimpleCAD.Polygon poly = new SimpleCAD.Polygon(new PointF[] { new PointF(x1, y1), new PointF(x2, y2), new PointF(loadx2, loady2), new PointF(loadx1, loady1) }); poly.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); poly.FillStyle = new SimpleCAD.FillStyle(ShadingColor); Model.Add(poly); SimpleCAD.Text textI = new SimpleCAD.Text(loadx1, loady1, trapezoidalLoad.FXI.ToString("0.0") + ", " + trapezoidalLoad.FZI.ToString("0.0"), TextSize); textI.HorizontalAlignment = StringAlignment.Near; textI.VerticalAlignment = StringAlignment.Center; textI.Rotation = angle; textI.FontFamily = Font.Name; textI.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); Model.Add(textI); SimpleCAD.Text textJ = new SimpleCAD.Text(loadx2, loady2, trapezoidalLoad.FXJ.ToString("0.0") + ", " + trapezoidalLoad.FZJ.ToString("0.0"), TextSize); textJ.HorizontalAlignment = StringAlignment.Near; textJ.VerticalAlignment = StringAlignment.Center; textJ.Rotation = angle; textJ.FontFamily = Font.Name; textJ.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); Model.Add(textJ); } } } }
/// <summary> /// Adds a new frame uniform load. /// </summary> public void AddUniformLoad(AnalysisCase analysisCase, double fx, double fz) { Loads.Add(new FrameUniformLoad(analysisCase, fx, fz)); }
private void DrawNodeLoads(AnalysisCase analysisCase) { float textOffset = 0.5f * TextSize; foreach (Node n in mCurrentSection.AnalysisModel.Nodes) { foreach (NodeLoad load in n.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is NodePointLoad) { NodePointLoad pointLoad = load as NodePointLoad; string loadText = pointLoad.FX.ToString("0") + ", " + pointLoad.FZ.ToString("0") + ", " + pointLoad.MY.ToString("0"); SimpleCAD.Text text = new SimpleCAD.Text((float)n.X + textOffset / 2, (float)n.Z + textOffset / 2, loadText, TextSize); text.FontFamily = Font.Name; text.OutlineStyle = new SimpleCAD.OutlineStyle(DimensionColor); Model.Add(text); } } } }
public FrameUniformLoad(AnalysisCase analysisCase, double fx, double fz) : base(analysisCase) { FX = fx; FZ = fz; }
public void Update() { MinNodeDeformations.Clear(); MinReactions.Clear(); MinFrameInternalForces.Clear(); MaxNodeDeformations.Clear(); MaxReactions.Clear(); MaxFrameInternalForces.Clear(); if (IsEnvelope) { HasEnvelopeValues = true; } foreach (KeyValuePair <AnalysisCase, double> pair in acCoefficients) { AnalysisCase analysisCase = pair.Key; double coefficient = pair.Value; if (IsEnvelope) { MinNodeDeformations = MinNodeDeformations.Min(analysisCase.NodeDeformations.Multiply(coefficient)); MinReactions = MinReactions.Min(analysisCase.Reactions.Multiply(coefficient)); MinFrameInternalForces = MinFrameInternalForces.Min(analysisCase.FrameInternalForces.Multiply(coefficient)); MaxNodeDeformations = MaxNodeDeformations.Max(analysisCase.NodeDeformations.Multiply(coefficient)); MaxReactions = MaxReactions.Max(analysisCase.Reactions.Multiply(coefficient)); MaxFrameInternalForces = MaxFrameInternalForces.Max(analysisCase.FrameInternalForces.Multiply(coefficient)); } else { MinNodeDeformations = MinNodeDeformations.MultiplyAndAdd(coefficient, analysisCase.NodeDeformations); MinReactions = MinReactions.MultiplyAndAdd(coefficient, analysisCase.Reactions); MinFrameInternalForces = MinFrameInternalForces.MultiplyAndAdd(coefficient, analysisCase.FrameInternalForces); MaxNodeDeformations = MaxNodeDeformations.MultiplyAndAdd(coefficient, analysisCase.NodeDeformations); MaxReactions = MaxReactions.MultiplyAndAdd(coefficient, analysisCase.Reactions); MaxFrameInternalForces = MaxFrameInternalForces.MultiplyAndAdd(coefficient, analysisCase.FrameInternalForces); } } foreach (KeyValuePair <Combination, double> pair in coCoefficients) { Combination combination = pair.Key; double coefficient = pair.Value; combination.Update(); if (IsEnvelope || combination.HasEnvelopeValues) { HasEnvelopeValues = true; MinNodeDeformations = MinNodeDeformations.Min(combination.MinNodeDeformations.Multiply(coefficient)); MinReactions = MinReactions.Min(combination.MinReactions.Multiply(coefficient)); MinFrameInternalForces = MinFrameInternalForces.Min(combination.MinFrameInternalForces.Multiply(coefficient)); MaxNodeDeformations = MaxNodeDeformations.Max(combination.MaxNodeDeformations.Multiply(coefficient)); MaxReactions = MaxReactions.Max(combination.MaxReactions.Multiply(coefficient)); MaxFrameInternalForces = MaxFrameInternalForces.Max(combination.MaxFrameInternalForces.Multiply(coefficient)); } else { MinNodeDeformations = MinNodeDeformations.MultiplyAndAdd(coefficient, combination.MinNodeDeformations); MinReactions = MinReactions.MultiplyAndAdd(coefficient, combination.MinReactions); MinFrameInternalForces = MinFrameInternalForces.MultiplyAndAdd(coefficient, combination.MinFrameInternalForces); MaxNodeDeformations = MaxNodeDeformations.MultiplyAndAdd(coefficient, combination.MaxNodeDeformations); MaxReactions = MaxReactions.MultiplyAndAdd(coefficient, combination.MaxReactions); MaxFrameInternalForces = MaxFrameInternalForces.MultiplyAndAdd(coefficient, combination.MaxFrameInternalForces); } } }
private void DrawFrameMoments(AnalysisCase analysisCase) { DrawFrameMoments(analysisCase.FrameInternalForces); }
/// <summary> /// Adds a new frame uniform load. /// </summary> public void AddFrameUniformLoad(AnalysisCase analysisCase, Frame frame, double fx, double fz) { frame.AddUniformLoad(analysisCase, fx, fz); }
public NodeLoad(AnalysisCase analysisCase) { AnalysisCase = analysisCase; }
/// <summary> /// Adds a new node point load. /// </summary> public void AddPointLoad(AnalysisCase analysisCase, double fx, double fz, double my) { Loads.Add(new NodePointLoad(analysisCase, fx, fz, my)); }
/// <summary> /// Solves the system for the given load case. /// </summary> public void Run(AnalysisCase analysisCase) { AssignNodeIndices(); if (stiffnessMatrix == null) { BuildStiffnessMatrix(); } Vector<double> f = GetLoadVector(analysisCase); Vector<double> d = restrainedStiffnessMatrix.Solve(f); CalculateDeformations(analysisCase, d); Vector<double> r = stiffnessMatrix * d; CalculateReactions(analysisCase, r); CalculateFrameInternalForces(analysisCase, d); }
/// <summary> /// Calculates node deformations for the given load case and deformation vector. /// </summary> private void CalculateDeformations(AnalysisCase analysisCase, Vector<double> deformations) { analysisCase.NodeDeformations.Clear(); for (int i = 0; i < nodes.Count; i++) { int j = nodes[i].Index; NodeDeformation d = new NodeDeformation(nodes[i], deformations[j * 3], deformations[j * 3 + 1], deformations[j * 3 + 2]); analysisCase.NodeDeformations.Add(d); } }
/// <summary> /// Calculates support reactions for the given load case and deformation vector. /// </summary> private void CalculateReactions(AnalysisCase analysisCase, Vector<double> reactions) { analysisCase.Reactions.Clear(); for (int i = 0; i < nodes.Count; i++) { int j = nodes[i].Index; if (nodes[i].Restraints != DOF.Free) { Reaction r = new Reaction(nodes[i], reactions[j * 3], reactions[j * 3 + 1], reactions[j * 3 + 2]); analysisCase.Reactions.Add(r); } } }
/// <summary> /// Returns the load vector for the given load case. /// </summary> private Vector <double> GetLoadVector(AnalysisCase analysisCase) { Vector <double> p = Vector <double> .Build.Dense(nodes.Count * 3, 0); // Node loads foreach (Node node in nodes) { foreach (NodeLoad load in node.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is NodePointLoad) { // Applied point loads NodePointLoad pl = (NodePointLoad)load; int i = node.Index; p[i * 3 + 0] += pl.FX; p[i * 3 + 1] += pl.FZ; p[i * 3 + 2] += pl.MY; } } } // Frame loads foreach (Frame frame in Frames) { double l = frame.Length; int i = frame.NodeI.Index; int j = frame.NodeJ.Index; foreach (FrameLoad load in frame.Loads.FindAll((e) => e.AnalysisCase == analysisCase)) { if (load is FrameUniformLoad) { // Frame fixed-end reactions from frame uniform loads FrameUniformLoad pl = (FrameUniformLoad)load; double fx = pl.FX * l / 2.0; double fz = pl.FZ * l / 2.0; p[i * 3 + 0] += fx; p[i * 3 + 1] += fz; p[i * 3 + 2] += 0; // End moment p[j * 3 + 0] += fx; p[j * 3 + 1] += fz; p[j * 3 + 2] += 0; // End moment } else if (load is FrameTrapezoidalLoad) { // Frame fixed-end reactions from frame trapezoidal loads FrameTrapezoidalLoad pl = (FrameTrapezoidalLoad)load; double fx = (pl.FXI + pl.FXJ) / 2.0 * l / 2.0; double fz = (pl.FZI + pl.FZJ) / 2.0 * l / 2.0; p[i * 3 + 0] += fx; p[i * 3 + 1] += fz; p[i * 3 + 2] += 0; // End moment p[j * 3 + 0] += fx; p[j * 3 + 1] += fz; p[j * 3 + 2] += 0; // End moment } } } // Set restrained node coefficients to 0 foreach (Node n in nodes) { if ((n.Restraints & DOF.UX) != DOF.Free) { p[n.Index * 3 + 0] = 0; } if ((n.Restraints & DOF.UZ) != DOF.Free) { p[n.Index * 3 + 1] = 0; } if ((n.Restraints & DOF.RY) != DOF.Free) { p[n.Index * 3 + 2] = 0; } } return(p); }
public void SetCoefficient(double coefficient, AnalysisCase analysisCase) { if (acCoefficients.ContainsKey(analysisCase)) acCoefficients[analysisCase] = coefficient; else acCoefficients.Add(analysisCase, coefficient); }