structuraid_core 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/structuraid_core/design_codes/aci_318_19/rc/footings/bending_reinforcement_ratio.rb +65 -0
  3. data/lib/structuraid_core/design_codes/aci_318_19/rc/footings/min_height.rb +27 -0
  4. data/lib/structuraid_core/design_codes/aci_318_19/rc/footings/one_way_shear_capacity.rb +29 -0
  5. data/lib/structuraid_core/design_codes/aci_318_19/rc/footings/punching_critical_section_perimeter.rb +105 -0
  6. data/lib/structuraid_core/design_codes/aci_318_19/rc/minimum_steel_cover.rb +55 -0
  7. data/lib/structuraid_core/design_codes/aci_318_19/rc/reduction_factor.rb +88 -0
  8. data/lib/structuraid_core/design_codes/nsr_10/rc/footings/bending_reinforcement_ratio.rb +66 -0
  9. data/lib/structuraid_core/design_codes/nsr_10/rc/footings/min_height.rb +38 -0
  10. data/lib/structuraid_core/design_codes/nsr_10/rc/footings/one_way_shear_capacity.rb +31 -0
  11. data/lib/structuraid_core/design_codes/nsr_10/rc/footings/punching_critical_section_perimeter.rb +103 -0
  12. data/lib/structuraid_core/design_codes/nsr_10/rc/minimum_steel_cover.rb +57 -0
  13. data/lib/structuraid_core/design_codes/nsr_10/rc/reduction_factor.rb +82 -0
  14. data/lib/structuraid_core/design_codes/schemas/rc/footings/bending_reinforcement_ratio_schema.rb +24 -0
  15. data/lib/structuraid_core/design_codes/schemas/rc/footings/min_height_schema.rb +16 -0
  16. data/lib/structuraid_core/design_codes/schemas/rc/footings/one_way_shear_capacity_schema.rb +22 -0
  17. data/lib/structuraid_core/design_codes/schemas/rc/footings/punching_critical_section_perimeter_schema.rb +23 -0
  18. data/lib/structuraid_core/design_codes/schemas/rc/minimum_steel_cover_schema.rb +32 -0
  19. data/lib/structuraid_core/design_codes/schemas/rc/reduction_factor_schema.rb +17 -0
  20. data/lib/structuraid_core/design_codes/utils/schema_definition.rb +38 -9
  21. data/lib/structuraid_core/elements/column/rectangular.rb +5 -4
  22. data/lib/structuraid_core/elements/footing.rb +37 -1
  23. data/lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb +17 -9
  24. data/lib/structuraid_core/engineering/analysis/footing/base.rb +17 -0
  25. data/lib/structuraid_core/engineering/analysis/footing/centric_combined_two_columns.rb +99 -0
  26. data/lib/structuraid_core/engineering/analysis/footing/centric_isolated.rb +5 -2
  27. data/lib/structuraid_core/engineering/analysis/footing/utils/basic_geometry.rb +36 -0
  28. data/lib/structuraid_core/engineering/analysis/footing/utils/centroid.rb +33 -0
  29. data/lib/structuraid_core/engineering/analysis/footing/utils/one_way_moment.rb +63 -0
  30. data/lib/structuraid_core/engineering/analysis/footing/utils/one_way_shear.rb +46 -0
  31. data/lib/structuraid_core/engineering/base.rb +1 -2
  32. data/lib/structuraid_core/engineering/locations/absolute.rb +15 -3
  33. data/lib/structuraid_core/engineering/locations/base.rb +2 -0
  34. data/lib/structuraid_core/engineering/locations/collection.rb +51 -0
  35. data/lib/structuraid_core/engineering/locations/coordinates_system.rb +75 -0
  36. data/lib/structuraid_core/engineering/locations/relative.rb +44 -1
  37. data/lib/structuraid_core/errors/design_codes/requirement_not_fulfilled_error.rb +15 -0
  38. data/lib/structuraid_core/errors/engineering/locations/duplicate_label_error.rb +13 -0
  39. data/lib/structuraid_core/loads/point_load.rb +3 -2
  40. data/lib/structuraid_core/version.rb +1 -1
  41. metadata +44 -3
  42. data/lib/structuraid_core/engineering/vector.rb +0 -35
@@ -0,0 +1,46 @@
1
+ module StructuraidCore
2
+ module Engineering
3
+ module Analysis
4
+ module Footing
5
+ module Utils
6
+ module OneWayShear
7
+ def shear_at(x_distance)
8
+ return [] if x_distance > section_length || x_distance.negative?
9
+
10
+ shear = [
11
+ shear_stretch_1(x_distance),
12
+ shear_stretch_2(x_distance),
13
+ shear_stretch_3(x_distance)
14
+ ].select(&:nonzero?)
15
+ return [0] if shear.empty?
16
+
17
+ shear
18
+ end
19
+
20
+ private
21
+
22
+ def shear_stretch_1(x_distance)
23
+ return 0.0 if x_distance > length_border_to_first_column || x_distance.zero?
24
+
25
+ -solicitation_load * x_distance
26
+ end
27
+
28
+ def shear_stretch_2(x_distance)
29
+ local_length_1 = length_border_to_first_column
30
+ local_length_2 = length_first_column_to_second_column
31
+ return 0.0 if x_distance < local_length_1 || x_distance > local_length_1 + local_length_2
32
+
33
+ -reaction_at_first_column - solicitation_load * x_distance
34
+ end
35
+
36
+ def shear_stretch_3(x_distance)
37
+ return 0.0 if x_distance < length_border_to_first_column + length_first_column_to_second_column
38
+
39
+ -reaction_at_second_column - reaction_at_first_column - solicitation_load * x_distance
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -5,6 +5,5 @@ module StructuraidCore
5
5
  end
6
6
  end
7
7
 
8
- require_relative 'vector'
9
- require_relative 'analysis/footing/centric_isolated'
8
+ require_relative 'analysis/footing/base'
10
9
  require_relative 'locations/base'
@@ -1,8 +1,10 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Engineering
3
5
  module Locations
4
6
  class Absolute < Base
5
- attr_accessor :value_x, :value_y, :value_z
7
+ attr_reader :value_x, :value_y, :value_z
6
8
 
7
9
  def initialize(value_x:, value_y:, value_z:)
8
10
  @value_x = value_x.to_f
@@ -10,8 +12,18 @@ module StructuraidCore
10
12
  @value_z = value_z.to_f
11
13
  end
12
14
 
13
- def to_a
14
- [@value_x, @value_y, @value_z]
15
+ def to_matrix
16
+ Matrix.column_vector(
17
+ [
18
+ value_x,
19
+ value_y,
20
+ value_z
21
+ ]
22
+ )
23
+ end
24
+
25
+ def to_vector
26
+ Vector[value_x, value_y, value_z]
15
27
  end
16
28
  end
17
29
  end
@@ -9,3 +9,5 @@ end
9
9
 
10
10
  require_relative 'absolute'
11
11
  require_relative 'relative'
12
+ require_relative 'coordinates_system'
13
+ require_relative 'collection'
@@ -0,0 +1,51 @@
1
+ module StructuraidCore
2
+ module Engineering
3
+ module Locations
4
+ class Collection < Base
5
+ include Enumerable
6
+
7
+ def initialize
8
+ @locations = []
9
+ end
10
+
11
+ def each(&block)
12
+ locations.each(&block)
13
+ end
14
+
15
+ def add(location)
16
+ raise DuplicateLabelError, location.label if find_by_label(location.label)
17
+
18
+ locations.push(location)
19
+ end
20
+
21
+ def inspect
22
+ locations.inspect
23
+ end
24
+
25
+ def find_by_label(label)
26
+ locations.find { |location| location.label == label.to_sym }
27
+ end
28
+
29
+ def last
30
+ locations.last
31
+ end
32
+
33
+ def prepend(location)
34
+ locations.prepend(location)
35
+ end
36
+
37
+ def find_or_add_by_label(location)
38
+ add(location)
39
+ find_by_label(location.label)
40
+ rescue DuplicateLabelError => e
41
+ Warning.warn(e.message)
42
+ find_by_label(location.label)
43
+ end
44
+
45
+ private
46
+
47
+ attr_reader :locations
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,75 @@
1
+ require 'matrix'
2
+
3
+ module StructuraidCore
4
+ module Engineering
5
+ module Locations
6
+ class CoordinatesSystem < Base
7
+ attr_reader :relative_locations, :axis_1, :anchor_location
8
+
9
+ def initialize(anchor_location:)
10
+ @anchor_location = anchor_location
11
+ @relative_locations = Collection.new
12
+ @axis_1 = Vector[1.0, 0.0, 0.0]
13
+ @axis_3 = Vector[0.0, 0.0, 1.0]
14
+ end
15
+
16
+ def align_axis_1_with(vector:)
17
+ relative_locations.each { |relative_location| rotate_axes(relative_location, theta(vector)) }
18
+ @axis_1 = vector.normalize
19
+ end
20
+
21
+ def add_location(relative_location)
22
+ relative_locations.add(relative_location)
23
+ end
24
+
25
+ def add_location_from_vector(vector, label:)
26
+ relative_location = Relative.from_vector(vector, label:)
27
+ add_location(relative_location)
28
+ end
29
+
30
+ def find_or_add_location_from_vector(vector, label:)
31
+ relative_location = Relative.from_vector(vector, label:)
32
+
33
+ relative_locations.find_or_add_by_label(relative_location)
34
+ end
35
+
36
+ def axis_2
37
+ axis_3.cross_product axis_1
38
+ end
39
+
40
+ def find_location(label)
41
+ relative_locations.find_by_label(label)
42
+ end
43
+
44
+ private
45
+
46
+ attr_reader :axis_3
47
+
48
+ def theta(vector)
49
+ unitary_vector = vector.normalize
50
+ return Math.acos(axis_1.inner_product(unitary_vector)) if axis_1.cross_product(unitary_vector)[2].zero?
51
+
52
+ Math.asin(axis_1.cross_product(unitary_vector)[2])
53
+ end
54
+
55
+ def rotate_axes(relative_location, theta)
56
+ transformed = rotation_matrix(theta) * relative_location.to_matrix
57
+ transformed_vector = Vector[
58
+ transformed[0, 0],
59
+ transformed[1, 0],
60
+ transformed[2, 0]
61
+ ]
62
+ relative_location.update_from_vector(transformed_vector)
63
+ end
64
+
65
+ def rotation_matrix(theta)
66
+ Matrix[
67
+ [Math.cos(theta), Math.sin(theta), 0.0],
68
+ [-Math.sin(theta), Math.cos(theta), 0.0],
69
+ [0.0, 0.0, 1.0]
70
+ ]
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,13 +1,56 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Engineering
3
5
  module Locations
4
6
  class Relative < Base
7
+ attr_reader :label
5
8
  attr_accessor :value_1, :value_2, :value_3
6
9
 
7
- def initialize(value_1:, value_2:, value_3:)
10
+ def self.from_vector(vector, label: nil)
11
+ new(
12
+ value_1: vector[0],
13
+ value_2: vector[1],
14
+ value_3: vector[2],
15
+ label:
16
+ )
17
+ end
18
+
19
+ def self.from_matrix(matrix, label: nil)
20
+ new(
21
+ value_1: matrix[0, 0],
22
+ value_2: matrix[1, 0],
23
+ value_3: matrix[2, 0],
24
+ label:
25
+ )
26
+ end
27
+
28
+ def initialize(value_1:, value_2:, value_3:, label: nil)
8
29
  @value_1 = value_1.to_f
9
30
  @value_2 = value_2.to_f
10
31
  @value_3 = value_3.to_f
32
+
33
+ @label = label&.to_sym
34
+ end
35
+
36
+ def to_matrix
37
+ Matrix.column_vector(
38
+ [
39
+ value_1,
40
+ value_2,
41
+ value_3
42
+ ]
43
+ )
44
+ end
45
+
46
+ def update_from_vector(vector)
47
+ @value_1 = vector[0]
48
+ @value_2 = vector[1]
49
+ @value_3 = vector[2]
50
+ end
51
+
52
+ def to_vector
53
+ Vector[value_1, value_2, value_3]
11
54
  end
12
55
  end
13
56
  end
@@ -0,0 +1,15 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ class RequirementNotFulfilledError < StandardError
4
+ attr_reader :requirement, :message, :code_reference
5
+
6
+ def initialize(requirement, message, code_reference)
7
+ @requirement = requirement
8
+ @message = message
9
+ @code_reference = code_reference
10
+
11
+ super(message)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module StructuraidCore
2
+ module Engineering
3
+ module Locations
4
+ class DuplicateLabelError < StandardError
5
+ def initialize(label)
6
+ message = "location with label: #{label} already exists"
7
+
8
+ super(message)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,11 +2,12 @@ module StructuraidCore
2
2
  module Loads
3
3
  class PointLoad < Base
4
4
  attr_accessor :value
5
- attr_reader :location
5
+ attr_reader :location, :label
6
6
 
7
- def initialize(value:, location:)
7
+ def initialize(value:, location:, label: nil)
8
8
  @value = value.to_f
9
9
  @location = location
10
+ @label = label&.to_sym
10
11
  end
11
12
  end
12
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StructuraidCore
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structuraid_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pradaing
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.22.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: matrix
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.4.2
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.2
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -144,14 +158,32 @@ files:
144
158
  - lib/structuraid_core/db/base.rb
145
159
  - lib/structuraid_core/db/rebars.yml
146
160
  - lib/structuraid_core/design_codes/aci_318_19/rc/elastic_modulus.rb
161
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/bending_reinforcement_ratio.rb
162
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/min_height.rb
163
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/one_way_shear_capacity.rb
164
+ - lib/structuraid_core/design_codes/aci_318_19/rc/footings/punching_critical_section_perimeter.rb
147
165
  - lib/structuraid_core/design_codes/aci_318_19/rc/footings/punching_shear_capacity.rb
166
+ - lib/structuraid_core/design_codes/aci_318_19/rc/minimum_steel_cover.rb
167
+ - lib/structuraid_core/design_codes/aci_318_19/rc/reduction_factor.rb
148
168
  - lib/structuraid_core/design_codes/base.rb
149
169
  - lib/structuraid_core/design_codes/nsr_10/rc/elastic_modulus.rb
170
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/bending_reinforcement_ratio.rb
171
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/min_height.rb
172
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/one_way_shear_capacity.rb
173
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/punching_critical_section_perimeter.rb
150
174
  - lib/structuraid_core/design_codes/nsr_10/rc/footings/punching_shear_capacity.rb
175
+ - lib/structuraid_core/design_codes/nsr_10/rc/minimum_steel_cover.rb
176
+ - lib/structuraid_core/design_codes/nsr_10/rc/reduction_factor.rb
151
177
  - lib/structuraid_core/design_codes/resolver.rb
152
178
  - lib/structuraid_core/design_codes/schemas/empty_schema.rb
153
179
  - lib/structuraid_core/design_codes/schemas/rc/elastic_modulus_schema.rb
180
+ - lib/structuraid_core/design_codes/schemas/rc/footings/bending_reinforcement_ratio_schema.rb
181
+ - lib/structuraid_core/design_codes/schemas/rc/footings/min_height_schema.rb
182
+ - lib/structuraid_core/design_codes/schemas/rc/footings/one_way_shear_capacity_schema.rb
183
+ - lib/structuraid_core/design_codes/schemas/rc/footings/punching_critical_section_perimeter_schema.rb
154
184
  - lib/structuraid_core/design_codes/schemas/rc/footings/punching_shear_capacity_schema.rb
185
+ - lib/structuraid_core/design_codes/schemas/rc/minimum_steel_cover_schema.rb
186
+ - lib/structuraid_core/design_codes/schemas/rc/reduction_factor_schema.rb
155
187
  - lib/structuraid_core/design_codes/utils/code_requirement.rb
156
188
  - lib/structuraid_core/design_codes/utils/schema_definition.rb
157
189
  - lib/structuraid_core/elements/base.rb
@@ -164,17 +196,26 @@ files:
164
196
  - lib/structuraid_core/elements/reinforcement/straight_longitudinal.rb
165
197
  - lib/structuraid_core/elements/reinforcement/straight_longitudinal_layer.rb
166
198
  - lib/structuraid_core/elements/reinforcement/utils/rebar_data.rb
199
+ - lib/structuraid_core/engineering/analysis/footing/base.rb
200
+ - lib/structuraid_core/engineering/analysis/footing/centric_combined_two_columns.rb
167
201
  - lib/structuraid_core/engineering/analysis/footing/centric_isolated.rb
202
+ - lib/structuraid_core/engineering/analysis/footing/utils/basic_geometry.rb
203
+ - lib/structuraid_core/engineering/analysis/footing/utils/centroid.rb
204
+ - lib/structuraid_core/engineering/analysis/footing/utils/one_way_moment.rb
205
+ - lib/structuraid_core/engineering/analysis/footing/utils/one_way_shear.rb
168
206
  - lib/structuraid_core/engineering/base.rb
169
207
  - lib/structuraid_core/engineering/locations/absolute.rb
170
208
  - lib/structuraid_core/engineering/locations/base.rb
209
+ - lib/structuraid_core/engineering/locations/collection.rb
210
+ - lib/structuraid_core/engineering/locations/coordinates_system.rb
171
211
  - lib/structuraid_core/engineering/locations/relative.rb
172
- - lib/structuraid_core/engineering/vector.rb
173
212
  - lib/structuraid_core/errors/base.rb
174
213
  - lib/structuraid_core/errors/design_codes/missing_param_error.rb
214
+ - lib/structuraid_core/errors/design_codes/requirement_not_fulfilled_error.rb
175
215
  - lib/structuraid_core/errors/design_codes/unknown_design_code_error.rb
176
216
  - lib/structuraid_core/errors/design_codes/unrecognized_value_error.rb
177
217
  - lib/structuraid_core/errors/engineering/analysis/section_direction_error.rb
218
+ - lib/structuraid_core/errors/engineering/locations/duplicate_label_error.rb
178
219
  - lib/structuraid_core/errors/reinforcement/empty_layers.rb
179
220
  - lib/structuraid_core/errors/reinforcement/invalid_distribution_direction.rb
180
221
  - lib/structuraid_core/loads/base.rb
@@ -1,35 +0,0 @@
1
- module StructuraidCore
2
- module Engineering
3
- class Vector < Base
4
- attr_accessor :value_x, :value_y, :value_z
5
-
6
- def self.with_value(value:, direction:)
7
- new(
8
- value_x: value.to_f * direction[0],
9
- value_y: value.to_f * direction[1],
10
- value_z: value.to_f * direction[2]
11
- )
12
- end
13
-
14
- def initialize(value_x:, value_y:, value_z:)
15
- @value_x = value_x.to_f
16
- @value_y = value_y.to_f
17
- @value_z = value_z.to_f
18
- end
19
-
20
- def magnitude
21
- Math.sqrt(value_x**2 + value_y**2 + value_z**2)
22
- end
23
-
24
- def direction
25
- vector_magnitude = magnitude
26
-
27
- [
28
- @value_x / vector_magnitude,
29
- @value_y / vector_magnitude,
30
- @value_z / vector_magnitude
31
- ]
32
- end
33
- end
34
- end
35
- end