-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb08cfb
commit 2540357
Showing
4 changed files
with
437 additions
and
0 deletions.
There are no files selected for viewing
261 changes: 261 additions & 0 deletions
261
GsaGHTests/1_BaseParameters/5_Results/Collections/Member1dDisplacementsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using GsaGH.Parameters.Results; | ||
using GsaGHTests.Helper; | ||
using Xunit; | ||
|
||
namespace GsaGHTests.Parameters.Results { | ||
[Collection("GrasshopperFixture collection")] | ||
public class Member1dDisplacementsTests { | ||
|
||
private static readonly string MemberList = "all"; | ||
|
||
[Fact] | ||
public void Member1dDisplacementsMember1dIdsFromAnalysisCaseTest() { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignSimple, 1); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert member IDs | ||
var expectedIds = result.Model.Model.Members(MemberList).Keys.OrderBy(x => x).ToList(); | ||
Assert.Equal(expectedIds, resultSet.Ids); | ||
} | ||
|
||
[Fact] | ||
public void Member1dDisplacementsMember1dIdsFromCombinationCaseTest() { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignSimple, 1); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert member IDs | ||
var expectedIds = result.Model.Model.Members(MemberList).Keys.OrderBy(x => x).ToList(); | ||
Assert.Equal(expectedIds, resultSet.Ids); | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignSimple, 1); | ||
double expected = ExpectedAnalysisCaseValues(component).Max(); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert Max in set | ||
double max = TestsResultHelper.ResultsHelper(resultSet, component, true); | ||
Assert.Equal(expected, max); | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignSimple, 1); | ||
double expected = ExpectedCombinationCaseC1Values(component).Max(); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert Max in set | ||
double max = TestsResultHelper.ResultsHelper(resultSet, component, true); | ||
Assert.Equal(expected, max); | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignSimple, 1); | ||
double expected = ExpectedAnalysisCaseValues(component).Min(); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert Max in set | ||
double min = TestsResultHelper.ResultsHelper(resultSet, component, false); | ||
Assert.Equal(expected, min); | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsMinFromcombinationCaseTest(ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignSimple, 1); | ||
double expected = ExpectedCombinationCaseC1Values(component).Min(); | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, 5); | ||
|
||
// Assert Max in set | ||
double min = TestsResultHelper.ResultsHelper(resultSet, component, false); | ||
Assert.Equal(expected, min); | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignSimple, 1); | ||
List<double> expected = ExpectedAnalysisCaseValues(component); | ||
int positionsCount = 5; | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, positionsCount); | ||
|
||
// Assert result values | ||
int i = 0; | ||
foreach (int id in resultSet.Ids) { | ||
Collection<IDisplacement1d> displacementQuantity = resultSet.Subset[id]; | ||
|
||
// for analysis case results we expect 4 positions | ||
Assert.Single(displacementQuantity); | ||
var positions = Enumerable.Range(0, positionsCount) | ||
.Select(k => (double)k / (positionsCount - 1)).ToList(); | ||
foreach (double position in positions) { | ||
double x = TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], | ||
component); | ||
Assert.Equal(expected[i++], x); | ||
} | ||
} | ||
} | ||
|
||
[Theory] | ||
[InlineData(ResultVector6HelperEnum.X)] | ||
[InlineData(ResultVector6HelperEnum.Y)] | ||
[InlineData(ResultVector6HelperEnum.Z)] | ||
[InlineData(ResultVector6HelperEnum.Xyz)] | ||
[InlineData(ResultVector6HelperEnum.Xx)] | ||
[InlineData(ResultVector6HelperEnum.Yy)] | ||
[InlineData(ResultVector6HelperEnum.Zz)] | ||
[InlineData(ResultVector6HelperEnum.Xxyyzz)] | ||
public void Member1dDisplacementsValuesFromCombinationCaseTest( | ||
ResultVector6HelperEnum component) { | ||
// Assemble | ||
var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignSimple, 1); | ||
List<double> expectedP1 = ExpectedCombinationCaseC1Values(component); | ||
int positionsCount = 5; | ||
|
||
// Act | ||
ReadOnlyCollection<int> memberIds = result.MemberIds(MemberList); | ||
IResultSubset1d<IDisplacement1d, IDisplacement, ResultVector6<ExtremaKey1d>> resultSet | ||
= result.Member1dDisplacements.ResultSubset(memberIds, positionsCount); | ||
|
||
// Assert result values | ||
int i = 0; | ||
foreach (int id in resultSet.Ids) { | ||
Collection<IDisplacement1d> displacementQuantity = resultSet.Subset[id]; | ||
|
||
// for C1 case results we expect 1 permutation in the collection | ||
Assert.Single(displacementQuantity); | ||
|
||
var positions = Enumerable.Range(0, positionsCount) | ||
.Select(k => (double)k / (positionsCount - 1)).ToList(); | ||
foreach (double position in positions) { | ||
double perm1 | ||
= TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], component); | ||
Assert.Equal(expectedP1[i], perm1); | ||
} | ||
} | ||
} | ||
|
||
private List<double> ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { | ||
switch (component) { | ||
case ResultVector6HelperEnum.X: return Member1dDisplacementsA1.XInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Y: return Member1dDisplacementsA1.YInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Z: return Member1dDisplacementsA1.ZInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Xyz: return Member1dDisplacementsA1.XyzInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Xx: return Member1dDisplacementsA1.XxInRadian(); | ||
|
||
case ResultVector6HelperEnum.Yy: return Member1dDisplacementsA1.YyInRadian(); | ||
|
||
case ResultVector6HelperEnum.Zz: return Member1dDisplacementsA1.ZzInRadian(); | ||
|
||
case ResultVector6HelperEnum.Xxyyzz: return Member1dDisplacementsA1.XxyyzzInRadian(); | ||
} | ||
|
||
throw new NotImplementedException(); | ||
} | ||
|
||
private List<double> ExpectedCombinationCaseC1Values(ResultVector6HelperEnum component) { | ||
switch (component) { | ||
case ResultVector6HelperEnum.X: return Member1dDisplacementsC1.XInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Y: return Member1dDisplacementsC1.YInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Z: return Member1dDisplacementsC1.ZInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Xyz: return Member1dDisplacementsC1.XyzInMillimeter(); | ||
|
||
case ResultVector6HelperEnum.Xx: return Member1dDisplacementsC1.XxInRadian(); | ||
|
||
case ResultVector6HelperEnum.Yy: return Member1dDisplacementsC1.YyInRadian(); | ||
|
||
case ResultVector6HelperEnum.Zz: return Member1dDisplacementsC1.ZzInRadian(); | ||
|
||
case ResultVector6HelperEnum.Xxyyzz: return Member1dDisplacementsC1.XxyyzzInRadian(); | ||
} | ||
|
||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...BaseParameters/5_Results/Collections/RegressionValues/Member1d/Member1dDisplacementsA1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace GsaGHTests.Parameters.Results { | ||
public class Member1dDisplacementsA1 { | ||
// these are regression tests, the values are taken directly from GSA results | ||
// "Steel_Design_Simplex.gwb" for all members for analysis case A1 with 5 positions | ||
internal static List<double> XInMillimeter() { | ||
return new List<double>() { | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
}; | ||
} | ||
|
||
internal static List<double> YInMillimeter() { | ||
return new List<double>() { | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
}; | ||
} | ||
|
||
internal static List<double> ZInMillimeter() { | ||
return new List<double>() { | ||
0.0, | ||
-3.639, | ||
-5.097, | ||
-3.639, | ||
0.0, | ||
}; | ||
} | ||
|
||
internal static List<double> XyzInMillimeter() { | ||
return new List<double>() { | ||
0.0, | ||
3.639, | ||
5.097, | ||
3.639, | ||
0.0, | ||
}; | ||
} | ||
|
||
internal static List<double> XxInRadian() { | ||
return new List<double>() { | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
}; | ||
} | ||
|
||
internal static List<double> YyInRadian() { | ||
return new List<double>() { | ||
0.002196, | ||
0.001490, | ||
0.0, | ||
-0.001490, | ||
-0.002196, | ||
}; | ||
} | ||
|
||
internal static List<double> ZzInRadian() { | ||
return new List<double>() { | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
}; | ||
} | ||
|
||
internal static List<double> XxyyzzInRadian() { | ||
return new List<double>() { | ||
0.002196, | ||
0.001490, | ||
0.0, | ||
0.001490, | ||
0.002196, | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.