-
Notifications
You must be signed in to change notification settings - Fork 0
/
resistance.go
174 lines (144 loc) · 4.15 KB
/
resistance.go
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
package bolt
import (
"fmt"
"math"
)
// Force - type of force
type Force float64
func (f Force) String() string {
return fmt.Sprintf("%.1f kN", float64(f)*1e-3)
}
// Factor - type of factors
type Factor float64
func (f Factor) String() string {
return fmt.Sprintf("%.3f", float64(f))
}
// ανThreadShear - factor if shear by thread of bolt
var ανThreadShear = map[Class]Factor{
G4p6: 0.6,
G4p8: 0.5,
G5p6: 0.6,
G5p8: 0.5,
G6p8: 0.5,
G8p8: 0.6,
G10p9: 0.5,
}
// ανThreadShear - factor if shear not by thread of bolt
var ανUnthreadShear Factor = 0.6
// PositionShear - position of shear on thread or not
type PositionShear bool
// Constants
const (
ThreadShear PositionShear = false
UnthreadShear = true
)
func (pos PositionShear) String() string {
if pos == ThreadShear {
return "Shear plane passes through the threaded portion of the bolt"
}
return "Shear plane passes through the unthreaded portion of the bolt"
}
// FactorγM2 - factor
var FactorγM2 Factor = 1.25
// ShearResistance - force of resistance on shear
type ShearResistance struct {
B Bolt
Position PositionShear
}
func (sr ShearResistance) αν() Factor {
switch sr.Position {
case UnthreadShear:
return ανUnthreadShear
}
//case ThreadShear:
return ανThreadShear[sr.B.bc]
}
// Value - return Force of shear resistance
func (sr ShearResistance) Value() Force {
return Force(float64(sr.αν()) * float64(sr.B.Fub().Value()) * float64(sr.B.As().Value()) / float64(FactorγM2))
}
func (sr ShearResistance) String() (s string) {
s += fmt.Sprintf("Calculation of shear resistance for %s%s:\n", sr.B.bd, sr.B.bc)
s += fmt.Sprintf("\tγM2 = %s\n", FactorγM2)
s += fmt.Sprintf("\tαν = %s - %s\n", sr.αν(), sr.Position)
s += fmt.Sprintf("\tFub = %s\n", sr.B.Fub().Value())
s += fmt.Sprintf("\tAs = %s\n", sr.B.As().Value())
s += "\tIn according to table 3.4 EN1993-1-8:\n"
s += fmt.Sprintf("\tShear resistance is %s", sr.Value())
return
}
// Type - configuration of bolt
type Type bool
// Constants
const (
UsuallyBolt Type = false
CountersunkBolt = true
)
func (bt Type) String() string {
if bt { // == CountersunkBolt
return "countersunk bolt"
}
return "no-countersunk bolt"
}
// TensionResistance - force of resistance on tension
type TensionResistance struct {
B Bolt
BT Type
}
// K2 - Factor
func (t TensionResistance) K2() Factor {
if t.BT { // == CountersunkBolt
return Factor(0.63)
}
return 0.9
}
// Value - return Force of tension resistance
func (t TensionResistance) Value() Force {
return Force(float64(t.K2()) * float64(t.B.Fub().Value()) * float64(t.B.As().Value()) / float64(FactorγM2))
}
func (t TensionResistance) String() (s string) {
s += fmt.Sprintf("Calculation of tension resistance for %s%s:\n", t.B.bd, t.B.bc)
s += fmt.Sprintf("\tγM2 = %s\n", FactorγM2)
s += fmt.Sprintf("\tk2 = %s - %s\n", t.K2(), t.BT)
s += fmt.Sprintf("\tFub = %s\n", t.B.Fub().Value())
s += fmt.Sprintf("\tAs = %s\n", t.B.As().Value())
s += "\tIn according to table 3.4 EN1993-1-8:\n"
s += fmt.Sprintf("\tTension resistance is %s", t.Value())
return
}
// Resistance - combined resistance shear and tension
type Resistance struct {
B Bolt
BT Type
Position PositionShear
}
// ViewResult - type of result view
type ViewResult int
// ViewResult constants
const (
NoView ViewResult = iota
FullView
)
// Value - return result of combined resistance calculation
func (r Resistance) Value(FvEd, FtEd Force, view ViewResult) (_ Factor, s string) {
max := 0.0
FvRd := ShearResistance{B: r.B, Position: r.Position}
f1 := float64(FvEd) / float64(FvRd.Value())
if view == FullView {
s += fmt.Sprintf("%s\n", FvRd)
s += fmt.Sprintf("Factor %s\n", Factor(f1))
}
max = math.Max(max, f1)
FtRd := TensionResistance{B: r.B, BT: r.BT}
f2 := float64(FtEd) / float64(FtRd.Value())
if view == FullView {
s += fmt.Sprintf("%s\n", FtRd)
s += fmt.Sprintf("Factor %s\n", Factor(f2))
}
max = math.Max(max, f2)
max = math.Max(max, float64(FvEd)/float64(FvRd.Value())+float64(FtEd)/(1.4*float64(FtRd.Value())))
if view == FullView {
s += fmt.Sprintf("Summary factor of combined loads is %s\n", Factor(max))
}
return Factor(max), s
}