public static LevelDictionary <PointDrift> GetDesignBoundaryCornerDrifts(LevelDataDictionary <RigidAnalysis> analyses) { var drifts = new LevelDictionary <PointDrift>(); List <BuildingLevelLateral2> sortedLevels = analyses.Select(l => l.Value.LateralLevel).OrderBy(l => l.Level.Elevation).ToList(); for (var i = 0; i < sortedLevels.Count; i++) { BuildingLevel level = sortedLevels[i].Level; RigidAnalysis analysis = analyses[level]; List <PointDrift> driftsAtLevel = DisplacementsWithUnknownDrifts(level, analysis.Responses.NodalLoadCaseResults.Values.SelectMany(r => r)); var storyHeight = sortedLevels[i].Height; if (i == 0) { // Lowest level; compare to ground driftsAtLevel.ForEach(d => { d.Drift = (Unitless)Result.Abs(d.Displacement / storyHeight); d.CoordinateBelow = d.Coordinate; d.DisplacementBelow = new Length(0, LengthUnit.Inch); }); } else { // Elevated level; compare to level below List <PointDrift> driftsAtLevelBelow = drifts[sortedLevels[i - 1].Level]; driftsAtLevel.ForEach(d => { PointDrift driftBelow = d.GetMatchingDriftAtLevelBelow(driftsAtLevelBelow); d.Drift = (Unitless)Result.Abs((d.Displacement - driftBelow.Displacement) / storyHeight); d.CoordinateBelow = driftBelow.Coordinate; d.DisplacementBelow = driftBelow.Displacement; }); } drifts.Add(level, driftsAtLevel); } return(drifts); }
/// <summary> /// Gets matching drift for an unsorted collection of Point Drifts, matching according to Load Case and Direction /// </summary> /// <param name="driftsAtLevelBelow"></param> /// <returns></returns> public PointDrift GetMatchingDriftAtLevelBelow(IEnumerable <PointDrift> driftsAtLevelBelow) { List <PointDrift> driftsToCompare = driftsAtLevelBelow.Where(d => d.LoadCase == LoadCase && d.Direction == Direction).ToList(); PointDrift closest = null; var closestDistance = Double.PositiveInfinity; for (var i = 0; i < driftsToCompare.Count; i++) { var other = driftsToCompare[i]; var distance = Coordinate.DistanceTo(other.Coordinate); if (distance < closestDistance) { closest = other; closestDistance = distance; } } return(closest); }
public static bool PredominantLoadDirectionCoincidesWithDriftDirection(PointDrift drift) { switch (drift.Direction) { case LateralDirection.X: switch (drift.LoadCase.PredominantDirection) { case PredominantDirection.X: case PredominantDirection.Both: return(true); case PredominantDirection.Y: return(false); default: throw new InvalidEnumArgumentException(); } case LateralDirection.Y: switch (drift.LoadCase.PredominantDirection) { case PredominantDirection.X: return(false); case PredominantDirection.Y: case PredominantDirection.Both: return(true); default: throw new InvalidEnumArgumentException(); } default: throw new InvalidEnumArgumentException(); } }