public static Unitless CalculateCs(double I_e, double S_1, double S_D1, double S_DS, Time T_L, double R, Time T, ref RecordedCalculation calculation) { Unitless C_s = Eqn_12_8_2(S_DS, R, I_e, ref calculation); if (T <= T_L) { Unitless C_s_12_8_3 = Eqn_12_8_3(S_D1, T, R, I_e, ref calculation); C_s = (Unitless)Result.Min(C_s_12_8_3, C_s); } else if (T > T_L) { Unitless C_s_12_8_4 = Eqn_12_8_4(S_D1, T_L, T, R, I_e, ref calculation); C_s = (Unitless)Result.Min(C_s_12_8_4, C_s); } Unitless C_s_12_8_5 = Eqn_12_8_5(S_DS, I_e, ref calculation); C_s = (Unitless)Result.Max(C_s, C_s_12_8_5); if (S_1 >= 0.6) { Unitless C_s_12_8_6 = Eqn_12_8_6(S_1, R, I_e, ref calculation); C_s = (Unitless)Result.Max(C_s, C_s_12_8_6); } return(C_s); }
private Force DetermineSeismicBaseShear() { var baseShearCalc = new RecordedCalculation("Seismic Parameter Calculations", CalculationType.SeismicDesign); var seismicParameters = _seismicProperties.SeismicParameters; double C_t = seismicParameters.SystemParameters.Ct; double X = seismicParameters.SystemParameters.X; double I_e = seismicParameters.BuildingParameters.ImportanceFactor; double S_1 = seismicParameters.Seismicity.SiteParameters.S1; double S_D1 = seismicParameters.Seismicity.SiteParameters.SD1; double S_DS = seismicParameters.Seismicity.SiteParameters.SDS; double R = seismicParameters.SystemParameters.R; Time T_L = new Time(seismicParameters.Seismicity.SiteParameters.TL); Force W = new Force(_seismicProperties.BuildingWeight, ForceUnit.Kip); Time T_a = Chapter_12.Section_12_8.Eqn_12_8_7(_buildingHeight, C_t, X, ref baseShearCalc); _fundamentalPeriod = T_a; Unitless C_s = Chapter_12.Section_12_8.CalculateCs(I_e, S_1, S_D1, S_DS, T_L, R, _fundamentalPeriod, ref baseShearCalc); // CalcLog.AddCalculation(baseShearCalc); return(Chapter_12.Section_12_8.Eqn_12_8_1(C_s, W, ref baseShearCalc)); }
public NodalDisplacement DetermineRigidbodyPointDisplacement(Point2D coordinate, LoadPattern loadPattern) { LateralLevelForce forceAtLoadPattern = Forces.First(f => f.LoadPattern == loadPattern); var alpha = new Unitless((coordinate - LateralLevel.CenterOfRigidity).SignedAngleTo(Vector2D.XAxis)); var d = new Length(coordinate.DistanceTo(LateralLevel.CenterOfRigidity), LengthUnit.Inch); Moment M = forceAtLoadPattern.TotalT(LateralLevel.CenterOfRigidity); var rotation = (Unitless)(M / LevelStiffness.J); Length displacementX = (Length)(forceAtLoadPattern.DirectX / LevelStiffness.X + d * rotation * Result.Sin(alpha)); Length displacementY = (Length)(forceAtLoadPattern.DirectY / LevelStiffness.Y + d * rotation * Result.Cos(alpha)); if (LoadPatternTypeConverter.Convert(loadPattern) == LoadPatternType.Earthquake) { displacementX = (Length)(displacementX * Cd); displacementY = (Length)(displacementY * Cd); } return(new NodalDisplacement { LoadPattern = loadPattern, Ux = displacementX.ConvertTo(LengthUnit.Inch), Uy = displacementY.ConvertTo(LengthUnit.Inch), Rz = 0 }); }
public void LengthTimesUnitlessEqualsLength() { var l = Length.FromMetres(1.2); var percents = Unitless.FromPercents(50); var actual = l * percents; Assert.IsInstanceOf <Length>(actual); Assert.AreEqual(Length.FromMetres(1.2 * 0.5), actual); }
private ShearWallPanelRigidAnalysisParameters DetermineWallStiffnessParametersSansOffset(AnalyticalWallLateral wall) { var wallVector = wall.WallLine.ToVector2D(); var wallAngleToXAxis = new Unitless(wallVector.SignedAngleTo(Vector2D.XAxis).Radians, UnitlessUnit.Radian); var k = new ForcePerLength(wall.Stiffness.ConvertTo(ForcePerLengthUnit.KipPerInch), ForcePerLengthUnit.KipPerInch); return(new ShearWallPanelRigidAnalysisParameters { K = k, AngleFromWallAxisToGlobalXAxis = wallAngleToXAxis }); }
/// <summary> /// Returns the seismic base shear of the building /// </summary> /// <param name="C_s">Seismic response coefficient determined in accordance with Section 12.8.1.1</param> /// <param name="W">Effective seismic weight per Section 12.7.2</param> /// <returns></returns> public static Force Eqn_12_8_1(Unitless C_s, Force W, ref RecordedCalculation calc) { string equationNumber = "12.8-1"; string expression = @"C_s W"; string resultDisplay = @"V"; SubCalculation subCalc = new SubCalculation(_standard, "Calculate seismic base shear of the building", Chapter, SectionNumber, equationNumber, expression, resultDisplay); subCalc.AddVariable("C_s", C_s, UnitlessUnit.Unitless); subCalc.AddVariable("W", W, ForceUnit.Kip); subCalc.Result = C_s * W; calc.AddCalculation(subCalc); return((Force)subCalc.Result); }
/// <summary> /// Calculates approximate fundamental period (T_a) for masonry or concrete shear wall structures /// </summary> /// <param name="C_w"></param> /// <param name="h_n"></param> /// <returns></returns> public static Time Eqn_12_8_9(Unitless C_w, Length h_n, ref RecordedCalculation Calculation) { string equationNumber = "12.8-9"; string expression = @"\frac{0.0019}{\sqrt{C_w}} h_n"; string resultDisplay = @"T_a"; SubCalculation subCalc = new SubCalculation(_standard, @"Calculate the approximate fundamental period", Chapter, SectionNumber, equationNumber, expression, resultDisplay); subCalc.AddVariable(new LaTexVariable("C_w", C_w, UnitlessUnit.Unitless)); subCalc.AddVariable(new LaTexVariable("h_n", h_n, LengthUnit.Foot)); subCalc.Result = new Time(0.0019 / Math.Sqrt(C_w.Value) * h_n.ConvertTo(LengthUnit.Foot)); Calculation.AddCalculation(subCalc); return((Time)subCalc.Result); }
/// <summary> /// Calculate the lateral seismic force induced at any level /// </summary> /// <param name="C_vx">Vertical distribution factor</param> /// <param name="V">Total design lateral force or shear at the base of the structure</param> /// <returns></returns> public static Force Eqn_12_8_11(Unitless C_vx, Force V, ref RecordedCalculation calc) { var equationNumber = "12.8-11"; var expression = @"C_{vx} V"; var resultDisplay = @"F_x"; SubCalculation subCalc = new SubCalculation(_standard, $"Calculate the lateral seismic force induced", Chapter, SectionNumber, equationNumber, expression, resultDisplay); subCalc.AddVariable(new LaTexVariable("C_{vx}", C_vx, UnitlessUnit.Unitless)); subCalc.AddVariable(new LaTexVariable("V", V, ForceUnit.Kip)); subCalc.Result = C_vx * V; calc.AddCalculation(subCalc); return((Force)subCalc.Result); }
private LevelDataDictionary <VerticalDistributionFactors> DetermineDistributionFactors() { var distributionFactors = new LevelDataDictionary <VerticalDistributionFactors>(); var k = 1.0; if (_fundamentalPeriod.Value > 0.5 && _fundamentalPeriod.Value < 2.5) { k = 1.0 + (_fundamentalPeriod.Value - 0.5) / 2d; } else if (_fundamentalPeriod.Value >= 2.5) { k = 2.0; } List <Force> w = _levels.Select(l => l.SeismicWeight).ToList(); List <Length> H = _levels.Select(l => l.Height).ToList(); var n = _levels.Count; var calc = new RecordedCalculation("Vertical Distribution Factors", CalculationType.SeismicDesign); foreach (BuildingLevelLateral2 level in _levels) { Force w_x = level.SeismicWeight; Length h_x = level.Height; Unitless C_vxi = Chapter_12.Section_12_8.Eqn_12_8_12(w_x, h_x, k, n, w, H, ref calc); distributionFactors.Add(new VerticalDistributionFactors { Level = level.Level, X = C_vxi, Y = C_vxi }); } // CalcLog.AddCalculation(calc); return(distributionFactors); }
/// <summary> /// Initializes a new instance of the <see cref="Gu.Units.Wpf.UnitlessExtension"/> class. /// </summary> /// <param name="value"><see cref="Gu.Units.Unitless"/>.</param> public UnitlessExtension(Unitless value) { this.Value = value; }
/// <inheritdoc /> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var stringValue = reader.Value as string; return(Unitless.Parse(stringValue, serializer.Culture)); }
/// <inheritdoc /> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!this.initialized) { Initialize(); } var message = this.errorText.ToString(); if (!(targetType == typeof(Unitless) || targetType == typeof(Unitless?))) { message += $"{GetType().Name} does not support converting to {targetType.Name}"; } if (message != string.Empty) { message = message.TrimEnd('\r', '\n'); if (Is.DesignMode) { throw new InvalidOperationException(message); } return(message); } if (value == null) { return(null); } if (value is double) { return(new Unitless((double)value, this.unit.Value)); } var text = value as string; if (string.IsNullOrEmpty(text)) { return(null); } var unitInput = UnitInput ?? Wpf.UnitInput.ScalarOnly; switch (unitInput) { case Wpf.UnitInput.ScalarOnly: { double d; if (double.TryParse(text, NumberStyles.Float, culture, out d)) { return(new Unitless(d, this.unit.Value)); } Unitless result; if (Unitless.TryParse(text, NumberStyles.Float, culture, out result)) { return($"#{text}#"); // returning modified text so that TypeConverter fails and we get an error } return(text); // returning raw to trigger error } case Wpf.UnitInput.SymbolAllowed: { double d; int pos = 0; WhiteSpaceReader.TryRead(text, ref pos); if (DoubleReader.TryRead(text, ref pos, NumberStyles.Float, culture, out d)) { WhiteSpaceReader.TryRead(text, ref pos); if (pos == text.Length) { return(new Unitless(d, this.unit.Value)); } } goto case Wpf.UnitInput.SymbolRequired; } case Wpf.UnitInput.SymbolRequired: { Unitless result; if (Unitless.TryParse(text, NumberStyles.Float, culture, out result)) { return(result); } return(text); } default: throw new ArgumentOutOfRangeException(); } }
protected void SetScalarValue(DependencyProperty property, Unitless? quantity) { // we set this flag to prevent from setting scalar value changing quantity values. this.isUpdatingScalarValue = true; var value = quantity != null ? this.Unit.GetScalarValue(quantity.Value) : (double?)null; this.SetCurrentValue(property, value); this.isUpdatingScalarValue = false; }
protected virtual void OnMaxValueChanged(Unitless? oldValue, Unitless? newValue) { this.SetScalarValue(ScalarMaxValueProperty, newValue); }