-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindCrackLoadFunction.cs
175 lines (146 loc) · 5.4 KB
/
FindCrackLoadFunction.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System;
using AdSecGHCore.Constants;
using Oasys.AdSec;
using OasysUnits;
namespace AdSecCore.Functions {
public class FindCrackLoadFunction : IFunction {
public SectionSolutionParameter Solution { get; set; } = new SectionSolutionParameter {
Name = "Results",
NickName = "Res",
Description = "AdSec Results to perform serviceability check on",
Access = Access.Item,
Optional = false,
};
public LoadParameter BaseLoad { get; set; } = new LoadParameter {
Name = "BaseLoad",
NickName = "Ld",
Description = "AdSec Load to start the optimisation from",
Access = Access.Item,
Optional = false,
};
public StringParameter OptimisedLoad { get; set; } = new StringParameter {
Name = "OptimisedLoad",
NickName = "Opt",
Description = "Text input to select which load component to optimise for, X, YY or ZZ (default 'YY')",
Access = Access.Item,
Default = "YY",
};
public IntegerParameter LoadIncrement { get; set; } = new IntegerParameter {
Name = "Increment",
NickName = "Inc",
Description = "Increment the load in steps of this size [using Unit from Settings] (default 1)",
Access = Access.Item,
};
public LengthParameter MaximumCrack { get; set; } = new LengthParameter {
Name = "MaxCrack",
NickName = "Crk",
Description = "The maximum allowed crack width",
Access = Access.Item,
};
public LoadParameter SectionLoad { get; set; } = new LoadParameter {
Name = "Load",
NickName = "Ld",
Description = $"The section load under the applied action.{Environment.NewLine}If the applied deformation is outside the capacity range of the section, the returned load will be zero",
Access = Access.Item,
};
public CrackParameter MaximumCracking { get; set; } = new CrackParameter {
Name = "MaximumCrack",
NickName = "Crk",
Description = $"The crack result from Cracks that corresponds to the maximum crack width.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned maximum width crack result will be maximum double value",
Access = Access.Item,
};
public FuncAttribute Metadata { get; set; } = new FuncAttribute {
Name = "Find Crack Load",
NickName = "CrackLd",
Description = "Increases the load until set crack width is reached",
};
public Organisation Organisation { get; set; } = new Organisation {
Category = CategoryName.Name(),
SubCategory = SubCategoryName.Cat7(),
};
public virtual Attribute[] GetAllInputAttributes() {
return new Attribute[] {
Solution,
BaseLoad,
OptimisedLoad,
LoadIncrement,
MaximumCrack,
};
}
public virtual Attribute[] GetAllOutputAttributes() {
return new Attribute[] {
SectionLoad,
MaximumCracking,
};
}
private static bool IsFx(string loadComponent) {
switch (loadComponent.ToLower().Trim()) {
case "x":
case "xx":
case "fx":
case "fxx":
return true;
default:
return false;
}
}
private static bool IsMyy(string loadComponent) {
switch (loadComponent.ToLower().Trim()) {
case "y":
case "yy":
case "my":
case "myy":
return true;
default:
return false;
}
}
private static bool IsMzz(string loadComponent) {
switch (loadComponent.ToLower().Trim()) {
case "z":
case "zz":
case "mz":
case "mzz":
return true;
default:
return false;
}
}
private static void UpdatedLoad(string loadComponent, ref ILoad baseLoad, int increment) {
var forceUnit = ContextUnits.Instance.ForceUnit;
var momentUnit = ContextUnits.Instance.MomentUnit;
if (IsFx(loadComponent)) {
baseLoad = ILoad.Create(new Force(baseLoad.X.As(forceUnit) + increment, forceUnit), baseLoad.YY,
baseLoad.ZZ);
} else if (IsMyy(loadComponent)) {
baseLoad = ILoad.Create(baseLoad.X, new Moment(baseLoad.YY.As(momentUnit) + increment, momentUnit),
baseLoad.ZZ);
} else if (IsMzz(loadComponent)) {
baseLoad = ILoad.Create(baseLoad.X, baseLoad.YY,
new Moment(baseLoad.ZZ.As(momentUnit) + increment, momentUnit));
} else {
throw new ArgumentException($"Load component {loadComponent} is not supported.");
}
}
public void Compute() {
var lengthUnitGeometry = ContextUnits.Instance.LengthUnitGeometry;
var solution = Solution.Value;
var baseLoad = BaseLoad.Value;
var loadComponent = OptimisedLoad.Value;
var increment = LoadIncrement.Value;
var maxCrack = MaximumCrack.Value.ToUnit(lengthUnitGeometry);
var sls = solution.Solution.Serviceability.Check(baseLoad);
while (sls.MaximumWidthCrack.Width <= maxCrack) {
// update load
UpdatedLoad(loadComponent, ref baseLoad, increment);
sls = solution.Solution.Serviceability.Check(baseLoad);
}
// update load to one step back
UpdatedLoad(loadComponent, ref baseLoad, -increment);
sls = solution.Solution.Serviceability.Check(baseLoad);
SectionLoad.Value = sls.Load;
MaximumCracking.Value = new CrackLoad() { Load = sls.MaximumWidthCrack, Plane = solution.SectionDesign.LocalPlane };
}
}
}