public void CoefficientF_vReturnsValue2() { double S_1 = 0.45; SeismicSiteClass cl = SeismicSiteClass.D; CalcLog log = new CalcLog(); Site s = new Site(cl, null); double F_v = s.SiteCoefficientFv(S_1); double refValue = 1.55; double actualTolerance = EvaluateActualTolerance(F_v, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void CoefficientF_aReturnsValue2() { double S_S = 1.2; SeismicSiteClass cl = SeismicSiteClass.D; CalcLog log = new CalcLog(); Site s = new Site(cl, null); double F_a = s.SiteCoefficientFa(S_S); double refValue = 1.02; double actualTolerance = EvaluateActualTolerance(F_a, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void CoefficientF_vReturnsValue1() { double S_1 = 0.15; SeismicSiteClass cl = SeismicSiteClass.D; CalcLog log = new CalcLog(); Site s = new Site(cl, null); double F_v = s.SiteCoefficientFv(S_1); double refValue = 2.2; double actualTolerance = EvaluateActualTolerance(F_v, refValue); Assert.True(actualTolerance <= tolerance); }
public void CoefficientF_aReturnsValue1() { double S_S = 0.273; SeismicSiteClass cl = SeismicSiteClass.D; CalcLog log = new CalcLog(); Site s = new Site(cl, null); double F_a = s.SiteCoefficientFa(S_S); double refValue = 1.58; double actualTolerance = EvaluateActualTolerance(F_a, refValue); Assert.True(actualTolerance <= tolerance); }
private double GetSiteCoefficientF(double S, SeismicSiteClass SiteClass, SeismicSiteCoefficient SiteCoefficient) { double SiteCoefficientF = 0; #region Read Coefficient Data var Tv11 = new { S = 0.0, Site = SeismicSiteClass.A, F = 0.0, Coefficient = SeismicSiteCoefficient.Fa }; // sample //var SiteCoefficientList = (new[] { Tv11 }).ToList(); //create list using casting by example var SiteCoefficientList = ListFactory.MakeList(Tv11); using (StringReader reader = new StringReader(Resources.ASCE7_10T11_4_1AND2)) { string line; while ((line = reader.ReadLine()) != null) { string[] Vals = line.Split(','); if (Vals.Count() == 4) { double s = double.Parse(Vals[0], CultureInfo.InvariantCulture); SeismicSiteClass Class = (SeismicSiteClass)Enum.Parse(typeof(SeismicSiteClass), Vals[1]); double f = double.Parse(Vals[2], CultureInfo.InvariantCulture); SeismicSiteCoefficient Coeff = (SeismicSiteCoefficient)Enum.Parse(typeof(SeismicSiteCoefficient), Vals[3]); SiteCoefficientList.Add(new { S = s, Site = Class, F = f, Coefficient = Coeff }); } } } #endregion var FValues = from fa in SiteCoefficientList where (fa.Site == SiteClass && fa.Coefficient == SiteCoefficient) orderby fa.S select fa; var ResultList = (FValues.ToList()); //create list (LINQ immediate execution) var MinSValue = FValues.Min(fVal => fVal.S); var MaxSValue = FValues.Max(fVal => fVal.S); // Check for extreme values if (S <= MinSValue) { var MinEntry = from fa in FValues where (fa.Site == SiteClass && fa.S == MinSValue) select fa; SiteCoefficientF = MinEntry.ElementAt(0).F; } if (S >= MaxSValue) { var MaxEntry = from fa in FValues where (fa.Site == SiteClass && fa.S == MaxSValue) select fa; SiteCoefficientF = MaxEntry.ElementAt(0).F; } if (S > MinSValue && S < MaxSValue) { //Intermediate values int NumEntries = ResultList.Count(); for (int i = 0; i < NumEntries; i++) { var thisVal = ResultList[i]; if (i > 0 && i < NumEntries - 1) { if (thisVal.S >= ResultList[i - 1].S && thisVal.S <= ResultList[i + 1].S) { SiteCoefficientF = Interpolation.InterpolateLinear(ResultList[i - 1].S, ResultList[i - 1].F, ResultList[i + 1].S, ResultList[i + 1].F, S); } } } } //output switch (SiteCoefficient) { case SeismicSiteCoefficient.Fa: double Fa = SiteCoefficientF; #region Fa ICalcLogEntry FaEntry = new CalcLogEntry(); FaEntry.ValueName = "Fa"; FaEntry.AddDependencyValue("SS", Math.Round(S, 3)); FaEntry.AddDependencyValue("SiteClass", SiteClass.ToString()); FaEntry.Reference = "Short-period site coefficient"; FaEntry.DescriptionReference = "/Templates/Loads/ASCE7_10/Seismic/SeismicSiteCoefficientFa.docx"; FaEntry.FormulaID = "Table 11.4-1"; //reference to formula from code FaEntry.VariableValue = Fa.ToString(); #endregion this.AddToLog(FaEntry); break; case SeismicSiteCoefficient.Fv: double Fv = SiteCoefficientF; #region Fv ICalcLogEntry FvEntry = new CalcLogEntry(); FvEntry.ValueName = "Fv"; FvEntry.AddDependencyValue("Sone", Math.Round(S, 3)); FvEntry.AddDependencyValue("SiteClass", SiteClass.ToString()); FvEntry.Reference = "Long-period site coefficient"; FvEntry.DescriptionReference = "/Templates/Loads/ASCE7_10/Seismic/SeismicSiteCoefficientFv.docx"; FvEntry.FormulaID = null; //reference to formula from code FvEntry.VariableValue = Fv.ToString(); #endregion this.AddToLog(FvEntry); break; } return SiteCoefficientF; }
public Site(SeismicSiteClass Class, ICalcLog CalcLog) : base(CalcLog) { this.SiteClass = Class; }
private double GetSiteCoefficientF(double S, SeismicSiteClass SiteClass, SeismicSiteCoefficient SiteCoefficient) { double SiteCoefficientF = 0; #region Read Coefficient Data var Tv11 = new { S = 0.0, Site = SeismicSiteClass.A, F = 0.0, Coefficient = SeismicSiteCoefficient.Fa }; // sample //var SiteCoefficientList = (new[] { Tv11 }).ToList(); //create list using casting by example var SiteCoefficientList = ListFactory.MakeList(Tv11); using (StringReader reader = new StringReader(Resources.ASCE7_10T11_4_1AND2)) { string line; while ((line = reader.ReadLine()) != null) { string[] Vals = line.Split(','); if (Vals.Count() == 4) { double s = double.Parse(Vals[0], CultureInfo.InvariantCulture); SeismicSiteClass Class = (SeismicSiteClass)Enum.Parse(typeof(SeismicSiteClass), Vals[1]); double f = double.Parse(Vals[2], CultureInfo.InvariantCulture); SeismicSiteCoefficient Coeff = (SeismicSiteCoefficient)Enum.Parse(typeof(SeismicSiteCoefficient), Vals[3]); SiteCoefficientList.Add(new { S = s, Site = Class, F = f, Coefficient = Coeff }); } } } #endregion var FValues = from fa in SiteCoefficientList where (fa.Site == SiteClass && fa.Coefficient == SiteCoefficient) orderby fa.S select fa; var ResultList = (FValues.ToList()); //create list (LINQ immediate execution) var MinSValue = FValues.Min(fVal => fVal.S); var MaxSValue = FValues.Max(fVal => fVal.S); // Check for extreme values if (S <= MinSValue) { var MinEntry = from fa in FValues where (fa.Site == SiteClass && fa.S == MinSValue) select fa; SiteCoefficientF = MinEntry.ElementAt(0).F; } if (S >= MaxSValue) { var MaxEntry = from fa in FValues where (fa.Site == SiteClass && fa.S == MaxSValue) select fa; SiteCoefficientF = MaxEntry.ElementAt(0).F; } if (S > MinSValue && S < MaxSValue) { //Intermediate values int NumEntries = ResultList.Count(); for (int i = 0; i < NumEntries; i++) { var thisVal = ResultList[i]; if (i > 0 && i < NumEntries - 1) { if (thisVal.S >= ResultList[i - 1].S && thisVal.S <= ResultList[i + 1].S) { SiteCoefficientF = Interpolation.InterpolateLinear(ResultList[i - 1].S, ResultList[i - 1].F, ResultList[i + 1].S, ResultList[i + 1].F, S); } } } } //output switch (SiteCoefficient) { case SeismicSiteCoefficient.Fa: double Fa = SiteCoefficientF; #region Fa ICalcLogEntry FaEntry = new CalcLogEntry(); FaEntry.ValueName = "Fa"; FaEntry.AddDependencyValue("SS", Math.Round(S, 3)); FaEntry.AddDependencyValue("SiteClass", SiteClass.ToString()); FaEntry.Reference = "Short-period site coefficient"; FaEntry.DescriptionReference = "/Templates/Loads/ASCE7_10/Seismic/SeismicSiteCoefficientFa.docx"; FaEntry.FormulaID = "Table 11.4-1"; //reference to formula from code FaEntry.VariableValue = Fa.ToString(); #endregion this.AddToLog(FaEntry); break; case SeismicSiteCoefficient.Fv: double Fv = SiteCoefficientF; #region Fv ICalcLogEntry FvEntry = new CalcLogEntry(); FvEntry.ValueName = "Fv"; FvEntry.AddDependencyValue("Sone", Math.Round(S, 3)); FvEntry.AddDependencyValue("SiteClass", SiteClass.ToString()); FvEntry.Reference = "Long-period site coefficient"; FvEntry.DescriptionReference = "/Templates/Loads/ASCE7_10/Seismic/SeismicSiteCoefficientFv.docx"; FvEntry.FormulaID = null; //reference to formula from code FvEntry.VariableValue = Fv.ToString(); #endregion this.AddToLog(FvEntry); break; } return(SiteCoefficientF); }