Skip to content

Commit

Permalink
Merge pull request #32 from MagmaWorks/feature/loads
Browse files Browse the repository at this point in the history
Loads
  • Loading branch information
kpne authored Oct 10, 2024
2 parents b6bf855 + 7d5d2ce commit ee22202
Show file tree
Hide file tree
Showing 115 changed files with 5,206 additions and 3 deletions.
30 changes: 30 additions & 0 deletions Loads/Cases/Cases/Factory/ENImposedCaseFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.Linq;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public static partial class ENLoadCaseFactory
{
public static VariableCase CreateImposed(ImposedLoadCategory category, NationalAnnex nationalAnnex)
{
TableA1_1Properties factors = new ENTableA1_1Imposed().GetProperties(category, nationalAnnex);
return new VariableCase()
{
Characteristic = factors.Phi_0,
Frequent = factors.Phi_1,
QuasiPermanent = factors.Phi_2,
Name = $"Live loads Category {category.ToString().Last()}",
Nickname = $"Q",
};
}

public static VariableCase CreateImposed(IList<ILoad> loads, ImposedLoadCategory category, NationalAnnex nationalAnnex)
{
VariableCase loadCase = CreateImposed(category, nationalAnnex);
loadCase.Loads = loads;
return loadCase;
}
}
}
29 changes: 29 additions & 0 deletions Loads/Cases/Cases/Factory/ENSnowCaseFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public static partial class ENLoadCaseFactory
{
public static VariableCase CreateSnow(NationalAnnex nationalAnnex, bool altitudeAbove1000m)
{
TableA1_1Properties factors = new ENTableA1_1Snow().GetProperties(altitudeAbove1000m, nationalAnnex);
return new VariableCase()
{
Characteristic = factors.Phi_0,
Frequent = factors.Phi_1,
QuasiPermanent = factors.Phi_2,
Name = $"Snow loads",
Nickname = "S",
};
}

public static VariableCase CreateSnow(IList<ILoad> loads, NationalAnnex nationalAnnex, bool altitudeAbove1000m)
{
VariableCase loadCase = CreateSnow(nationalAnnex, altitudeAbove1000m);
loadCase.Loads = loads;
return loadCase;
}
}
}
59 changes: 59 additions & 0 deletions Loads/Cases/Cases/Factory/ENTableA1_1Imposed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
internal class ENTableA1_1Imposed : ITableA1_1Imposed
{
public TableA1_1Properties GetProperties(ImposedLoadCategory category, NationalAnnex nationalAnnex)
{
if (!EN1990_TableA1_1_Imposed.TryGetValue(
nationalAnnex, out Dictionary<ImposedLoadCategory, TableA1_1Properties> kvp))
{
throw new System.NotImplementedException(
$"NA {nationalAnnex} not implemented for EN1990 Table A1.1 Imposed Load φ-factors");
};

return kvp[category];
}

private static readonly Dictionary<NationalAnnex,
Dictionary<ImposedLoadCategory, TableA1_1Properties>> EN1990_TableA1_1_Imposed = new()
{
{ NationalAnnex.RecommendedValues, new () {
{ ImposedLoadCategory.CategoryA, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryB, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryC, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryD, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryE, new TableA1_1Properties(1.0, 0.9, 0.8) },
{ ImposedLoadCategory.CategoryF, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryG, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryH, new TableA1_1Properties(0.0, 0.0, 0.0) },
}
},
{ NationalAnnex.UnitedKingdom, new () {
{ ImposedLoadCategory.CategoryA, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryB, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryC, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryD, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryE, new TableA1_1Properties(1.0, 0.9, 0.8) },
{ ImposedLoadCategory.CategoryF, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryG, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryH, new TableA1_1Properties(0.7, 0.0, 0.0) },
}
},
{ NationalAnnex.Germany, new () {
{ ImposedLoadCategory.CategoryA, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryB, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryC, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryD, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryE, new TableA1_1Properties(1.0, 0.9, 0.8) },
{ ImposedLoadCategory.CategoryF, new TableA1_1Properties(0.7, 0.7, 0.6) },
{ ImposedLoadCategory.CategoryG, new TableA1_1Properties(0.7, 0.5, 0.3) },
{ ImposedLoadCategory.CategoryH, new TableA1_1Properties(0.0, 0.0, 0.0) },
}
},
};
}
}
32 changes: 32 additions & 0 deletions Loads/Cases/Cases/Factory/ENTableA1_1Snow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
internal class ENTableA1_1Snow : ITableA1_1Snow
{
public TableA1_1Properties GetProperties(bool above1000m, NationalAnnex nationalAnnex)
{
if (!EN1990_TableA1_1_Snow.TryGetValue(
nationalAnnex, out (TableA1_1Properties Above1000m, TableA1_1Properties Below1000m) kvp))
{
throw new System.NotImplementedException(
$"NA {nationalAnnex} not implemented for EN1990 Table A1.1 Snow φ-factors");
};

return above1000m ? kvp.Above1000m : kvp.Below1000m;
}

private static readonly Dictionary<NationalAnnex,
(TableA1_1Properties Above1000m, TableA1_1Properties Below1000m)> EN1990_TableA1_1_Snow = new()
{
{ NationalAnnex.RecommendedValues,
(new TableA1_1Properties(0.7, 0.5, 0.2), new TableA1_1Properties(0.5, 0.2, 0.0)) },
{ NationalAnnex.UnitedKingdom,
(new TableA1_1Properties(0.7, 0.5, 0.2), new TableA1_1Properties(0.5, 0.2, 0.0)) },
{ NationalAnnex.Germany,
(new TableA1_1Properties(0.7, 0.5, 0.2), new TableA1_1Properties(0.5, 0.2, 0.0)) },
};
}
}
27 changes: 27 additions & 0 deletions Loads/Cases/Cases/Factory/ENTableA1_1Thermal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
internal class ENTableA1_1Thermal : ITableA1_1
{
public TableA1_1Properties GetProperties(NationalAnnex nationalAnnex)
{
if (!EN1990_TableA1_1_Thermal.TryGetValue(nationalAnnex, out TableA1_1Properties factors))
{
throw new System.NotImplementedException(
$"NA {nationalAnnex} not implemented for EN1990 Table A1.1 Thermal φ-factors");
};

return factors;
}

private static readonly Dictionary<NationalAnnex, TableA1_1Properties> EN1990_TableA1_1_Thermal = new()
{
{ NationalAnnex.RecommendedValues, new TableA1_1Properties(0.6, 0.5, 0.0) },
{ NationalAnnex.UnitedKingdom, new TableA1_1Properties(0.6, 0.5, 0.0) },
{ NationalAnnex.Germany, new TableA1_1Properties(0.6, 0.5, 0.0) },
};
}
}
27 changes: 27 additions & 0 deletions Loads/Cases/Cases/Factory/ENTableA1_1Wind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
internal class ENTableA1_1Wind : ITableA1_1
{
public TableA1_1Properties GetProperties(NationalAnnex nationalAnnex)
{
if (!EN1990_TableA1_1_Wind.TryGetValue(nationalAnnex, out TableA1_1Properties factors))
{
throw new System.NotImplementedException(
$"NA {nationalAnnex} not implemented for EN1990 Table A1.1 Wind φ-factors");
};

return factors;
}

private static readonly Dictionary<NationalAnnex, TableA1_1Properties> EN1990_TableA1_1_Wind = new()
{
{ NationalAnnex.RecommendedValues, new TableA1_1Properties(0.6, 0.2, 0.0) },
{ NationalAnnex.UnitedKingdom, new TableA1_1Properties(0.6, 0.2, 0.0) },
{ NationalAnnex.Germany, new TableA1_1Properties(0.6, 0.2, 0.0) },
};
}
}
29 changes: 29 additions & 0 deletions Loads/Cases/Cases/Factory/ENThermalCaseFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public static partial class ENLoadCaseFactory
{
public static VariableCase CreateThermal(NationalAnnex nationalAnnex)
{
TableA1_1Properties factors = new ENTableA1_1Thermal().GetProperties(nationalAnnex);
return new VariableCase()
{
Characteristic = factors.Phi_0,
Frequent = factors.Phi_1,
QuasiPermanent = factors.Phi_2,
Name = $"Thermal loads",
Nickname = "T",
};
}

public static VariableCase CreateThermal(IList<ILoad> loads, NationalAnnex nationalAnnex)
{
VariableCase loadCase = CreateThermal(nationalAnnex);
loadCase.Loads = loads;
return loadCase;
}
}
}
30 changes: 30 additions & 0 deletions Loads/Cases/Cases/Factory/ENWindCaseFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases.EN;
using MagmaWorks.Taxonomy.Standards.Eurocode;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public static partial class ENLoadCaseFactory
{
public static VariableCase CreateWind(NationalAnnex nationalAnnex)
{
TableA1_1Properties factors = new ENTableA1_1Wind().GetProperties(nationalAnnex);
return new VariableCase()
{
Characteristic = factors.Phi_0,
Frequent = factors.Phi_1,
QuasiPermanent = factors.Phi_2,
Name = $"Wind loads",
Nickname = "W",
IsHorizontal = true,
};
}

public static VariableCase CreateWind(IList<ILoad> loads, NationalAnnex nationalAnnex)
{
VariableCase loadCase = CreateWind(nationalAnnex);
loadCase.Loads = loads;
return loadCase;
}
}
}
15 changes: 15 additions & 0 deletions Loads/Cases/Cases/PermanentCase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public class PermanentCase : IPermanentCase
{
public string Nickname { get; set; } = "G";
public bool IsFavourable { get; set; } = false;
public bool IsHorizontal { get; set; } = false;
public string Name { get; set; } = "Dead Load";
public IList<ILoad> Loads { get; set; } = new List<ILoad>();

public PermanentCase() { }
}
}
19 changes: 19 additions & 0 deletions Loads/Cases/Cases/VariableCase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using OasysUnits;

namespace MagmaWorks.Taxonomy.Loads.Cases
{
public class VariableCase : IVariableCase
{
public string Nickname { get; set; }
public bool IsFavourable { get; set; } = false;
public bool IsHorizontal { get; set; } = false;
public string Name { get; set; }
public Ratio Characteristic { get; set; }
public Ratio Frequent { get; set; }
public Ratio QuasiPermanent { get; set; }
public IList<ILoad> Loads { get; set; } = new List<ILoad>();

public VariableCase() { }
}
}
61 changes: 61 additions & 0 deletions Loads/Cases/Combinations/AccidentialCombination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using MagmaWorks.Taxonomy.Loads.Cases;
using OasysUnits;
using OasysUnits.Units;

namespace MagmaWorks.Taxonomy.Loads.Combinations
{
public class AccidentialCombination : IAccidentialCombination
{
public string Name { get; set; } = string.Empty;
public string Definition => GetDefinition();
public bool UseFrequentCombinationFactorForMainAccompanying { get; set; } = true;
public Ratio LeadingAccidentialPartialFactor { get; set; } = new Ratio(1, RatioUnit.DecimalFraction);
public IList<IPermanentCase> PermanentCases { get; set; } = new List<IPermanentCase>();
public IList<IVariableCase> LeadingVariableCases { get; set; } = new List<IVariableCase>();
public IList<IVariableCase> MainAccompanyingVariableCases { get; set; } = new List<IVariableCase>();
public IList<IVariableCase> OtherAccompanyingVariableCases { get; set; } = new List<IVariableCase>();

public AccidentialCombination() { }

public IList<ILoad> GetFactoredLoads()
{
var factoredLoads = new List<ILoad>();
factoredLoads.AddRange(Utility.GetLoads(PermanentCases));
factoredLoads.AddRange(
Utility.FactorLoads(LeadingAccidentialPartialFactor, LeadingVariableCases));
if (UseFrequentCombinationFactorForMainAccompanying)
{
factoredLoads.AddRange(Utility.SelectAccompanyingVariableLoads(
MainAccompanyingVariableCases, ld => ld.Frequent));
}
else
{
factoredLoads.AddRange(Utility.SelectAccompanyingVariableLoads(
MainAccompanyingVariableCases, ld => ld.QuasiPermanent));
}

factoredLoads.AddRange(Utility.SelectAccompanyingVariableLoads(
OtherAccompanyingVariableCases, ld => ld.QuasiPermanent));
return factoredLoads;
}

private string GetDefinition()
{
string perm = Utility.DescriptionHelper(PermanentCases, new Ratio(1, RatioUnit.DecimalFraction));
string lead = Utility.DescriptionHelper(LeadingVariableCases, LeadingAccidentialPartialFactor);
Func<IVariableCase, Ratio> selector = ld => ld.QuasiPermanent;
if (UseFrequentCombinationFactorForMainAccompanying)
{
selector = ld => ld.Frequent;
}

string main = Utility.DescriptionHelper(
MainAccompanyingVariableCases, new Ratio(1, RatioUnit.DecimalFraction), selector);
string other = Utility.DescriptionHelper(
OtherAccompanyingVariableCases, new Ratio(1, RatioUnit.DecimalFraction), ld => ld.QuasiPermanent);
return Utility.JoinDescriptions(new string[] { perm, lead, main, other });
}
}
}
Loading

0 comments on commit ee22202

Please sign in to comment.