structuraid_core 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b01de831b96f114f85f1e9b0942bb793140c50425a564bad135ce06cb2b56554
4
- data.tar.gz: 8bf897de647fe493060877279819266f495ee72cbaa843d815d588c7b8346932
3
+ metadata.gz: e6a3c25bdfad6f0af2c266ad01cf0321e74780e4366a9a0b941e37c108f6d152
4
+ data.tar.gz: 60afe6f91b70f5acd7ac3d12b1e0c33282afed9620f2c55ee2c29ada6fe3295f
5
5
  SHA512:
6
- metadata.gz: c4804e1b46845546e655da89afb6a5f37909226001645ce0117b2a6cc4bb29992a818c900541eb7e9bd49934feeb208eabf1519c344fac24e481b6a65a995d34
7
- data.tar.gz: 5498aca686ae447b04c983aca955e3008de5e83f8c63105001ec7ceb59858bf3904c91e71d88ba2d15847efa7a29408204ac75caaf92e9b66c7781153f1feac7
6
+ metadata.gz: fc6983c21cb7278bb90e9b2b3d4a68e6c873e1fd7de57205724344385200e4674c05fceb61c02342a4329c5ce1515636c614ec8c55d5dba6952f08cd595a309b
7
+ data.tar.gz: da91f2acb4102987f40c8d05b314727349782e0ac170859423460e131aa6b5793c4761066c583b0c6836d1db0392f47b574911faf75368fef61ebf4b4485497e
data/.rubocop.yml CHANGED
@@ -25,6 +25,12 @@ RSpec/MultipleMemoizedHelpers:
25
25
  RSpec/NestedGroups:
26
26
  Enabled: false
27
27
 
28
+ RSpec/ContainExactly:
29
+ Enabled: false
30
+
31
+ RSpec/MatchArray:
32
+ Enabled: false
33
+
28
34
  Lint/MissingSuper:
29
35
  Enabled: false
30
36
 
@@ -0,0 +1,27 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module ACI31819
4
+ module RC
5
+ module Footings
6
+ class MinHeight
7
+ include DesignCodes::Utils::CodeRequirement
8
+ use_schema DesignCodes::Schemas::RC::Footings::MinHeightSchema
9
+
10
+ MIN_HEIGHT = 150
11
+ CODE_REFERENCE = 'ACI 318-19 13.3.1.2'.freeze
12
+
13
+ def call
14
+ return true if bottom_rebar_effective_height >= MIN_HEIGHT
15
+
16
+ raise RequirementNotFulfilledError.new(
17
+ :min_height,
18
+ "Effective Height #{bottom_rebar_effective_height} is below #{MIN_HEIGHT} mininmum",
19
+ CODE_REFERENCE
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module NSR10
4
+ module RC
5
+ module Footings
6
+ class MinHeight
7
+ include DesignCodes::Utils::CodeRequirement
8
+ use_schema DesignCodes::Schemas::RC::Footings::MinHeightSchema
9
+
10
+ MIN_HEIGHT_MAPPINGS = {
11
+ over_soil: 150,
12
+ over_piles: 300
13
+ }.freeze
14
+
15
+ CODE_REFERENCE = 'NSR-10 C.15.7'.freeze
16
+
17
+ def call
18
+ support_type = params.support_type || :over_soil
19
+ unless MIN_HEIGHT_MAPPINGS.keys.include?(support_type)
20
+ raise UnrecognizedValueError.new(:support_type, support_type)
21
+ end
22
+
23
+ min_height = MIN_HEIGHT_MAPPINGS[support_type]
24
+
25
+ return true if bottom_rebar_effective_height >= min_height
26
+
27
+ raise RequirementNotFulfilledError.new(
28
+ :min_height,
29
+ "Height #{bottom_rebar_effective_height} is below #{min_height} mininmum",
30
+ CODE_REFERENCE
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ module StructuraidCore
2
+ module DesignCodes
3
+ module Schemas
4
+ module RC
5
+ module Footings
6
+ class MinHeightSchema
7
+ include DesignCodes::Utils::SchemaDefinition
8
+
9
+ required_params %i[bottom_rebar_effective_height]
10
+ optional_params %i[support_type]
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,5 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Elements
3
5
  module Reinforcement
@@ -44,7 +46,13 @@ module StructuraidCore
44
46
  offset ||= 0.5 * diameter
45
47
 
46
48
  [@start_location, @end_location].each do |location|
47
- location.value_3 = above_middle ? location.value_3 - offset : location.value_3 + offset
49
+ location.update_from_vector(
50
+ Vector[
51
+ location.value_1,
52
+ location.value_2,
53
+ above_middle ? location.value_3 - offset : location.value_3 + offset
54
+ ]
55
+ )
48
56
  end
49
57
  end
50
58
 
@@ -67,9 +75,9 @@ module StructuraidCore
67
75
  def length
68
76
  vector = length_vector
69
77
 
70
- vector.value_x = 0 if @distribution_direction == :length_1
71
- vector.value_y = 0 if @distribution_direction == :length_2
72
- vector.value_z = 0 if @distribution_direction == :length_3
78
+ vector[0] = 0 if @distribution_direction == :length_1
79
+ vector[1] = 0 if @distribution_direction == :length_2
80
+ vector[2] = 0 if @distribution_direction == :length_3
73
81
 
74
82
  vector.magnitude
75
83
  end
@@ -77,11 +85,11 @@ module StructuraidCore
77
85
  private
78
86
 
79
87
  def length_vector
80
- Engineering::Vector.new(
81
- value_x: @end_location.value_1 - @start_location.value_1,
82
- value_y: @end_location.value_2 - @start_location.value_2,
83
- value_z: @end_location.value_3 - @start_location.value_3
84
- )
88
+ Vector[
89
+ @end_location.value_1 - @start_location.value_1,
90
+ @end_location.value_2 - @start_location.value_2,
91
+ @end_location.value_3 - @start_location.value_3
92
+ ]
85
93
  end
86
94
  end
87
95
  end
@@ -7,7 +7,10 @@ module StructuraidCore
7
7
 
8
8
  def initialize(footing:, load_from_column:, section_direction:)
9
9
  if ORTHOGONALITIES.none?(section_direction)
10
- raise Engineering::Analysis::SectionDirectionError.new(section_direction, ORTHOGONALITIES)
10
+ raise Engineering::Analysis::SectionDirectionError.new(
11
+ section_direction,
12
+ ORTHOGONALITIES
13
+ )
11
14
  end
12
15
 
13
16
  @footing = footing
@@ -5,6 +5,5 @@ module StructuraidCore
5
5
  end
6
6
  end
7
7
 
8
- require_relative 'vector'
9
8
  require_relative 'analysis/footing/centric_isolated'
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,14 @@ 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
+ )
15
23
  end
16
24
  end
17
25
  end
@@ -9,3 +9,4 @@ end
9
9
 
10
10
  require_relative 'absolute'
11
11
  require_relative 'relative'
12
+ require_relative 'coordinates_system'
@@ -0,0 +1,60 @@
1
+ require 'matrix'
2
+
3
+ module StructuraidCore
4
+ module Engineering
5
+ module Locations
6
+ class CoordinatesSystem < Base
7
+ attr_reader :relative_locations, :axis_1
8
+
9
+ def initialize(anchor_location:, relative_locations: [])
10
+ @anchor_location = anchor_location
11
+ @relative_locations = relative_locations
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 << relative_location
23
+ end
24
+
25
+ def axis_2
26
+ axis_3.cross_product axis_1
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :axis_3
32
+
33
+ def theta(vector)
34
+ unitary_vector = vector.normalize
35
+ return Math.acos(axis_1.inner_product(unitary_vector)) if axis_1.cross_product(unitary_vector)[2].zero?
36
+
37
+ Math.asin(axis_1.cross_product(unitary_vector)[2])
38
+ end
39
+
40
+ def rotate_axes(relative_location, theta)
41
+ transformed = rotation_matrix(theta) * relative_location.to_matrix
42
+ transformed_vector = Vector[
43
+ transformed[0, 0],
44
+ transformed[1, 0],
45
+ transformed[2, 0]
46
+ ]
47
+ relative_location.update_from_vector(transformed_vector)
48
+ end
49
+
50
+ def rotation_matrix(theta)
51
+ Matrix[
52
+ [Math.cos(theta), Math.sin(theta), 0.0],
53
+ [-Math.sin(theta), Math.cos(theta), 0.0],
54
+ [0.0, 0.0, 1.0]
55
+ ]
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -1,14 +1,44 @@
1
+ require 'matrix'
2
+
1
3
  module StructuraidCore
2
4
  module Engineering
3
5
  module Locations
4
6
  class Relative < Base
5
- attr_accessor :value_1, :value_2, :value_3
7
+ attr_reader :value_1, :value_2, :value_3
8
+
9
+ def self.from_matrix(matrix)
10
+ new(
11
+ value_1: matrix[0, 0],
12
+ value_2: matrix[1, 0],
13
+ value_3: matrix[2, 0]
14
+ )
15
+ end
6
16
 
7
17
  def initialize(value_1:, value_2:, value_3:)
8
18
  @value_1 = value_1.to_f
9
19
  @value_2 = value_2.to_f
10
20
  @value_3 = value_3.to_f
11
21
  end
22
+
23
+ def to_matrix
24
+ Matrix.column_vector(
25
+ [
26
+ value_1,
27
+ value_2,
28
+ value_3
29
+ ]
30
+ )
31
+ end
32
+
33
+ def update_from_vector(vector)
34
+ @value_1 = vector[0]
35
+ @value_2 = vector[1]
36
+ @value_3 = vector[2]
37
+ end
38
+
39
+ def to_vector
40
+ Vector[value_1, value_2, value_3]
41
+ end
12
42
  end
13
43
  end
14
44
  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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StructuraidCore
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pradaing
@@ -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,13 +158,16 @@ 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/min_height.rb
147
162
  - lib/structuraid_core/design_codes/aci_318_19/rc/footings/punching_shear_capacity.rb
148
163
  - lib/structuraid_core/design_codes/base.rb
149
164
  - lib/structuraid_core/design_codes/nsr_10/rc/elastic_modulus.rb
165
+ - lib/structuraid_core/design_codes/nsr_10/rc/footings/min_height.rb
150
166
  - lib/structuraid_core/design_codes/nsr_10/rc/footings/punching_shear_capacity.rb
151
167
  - lib/structuraid_core/design_codes/resolver.rb
152
168
  - lib/structuraid_core/design_codes/schemas/empty_schema.rb
153
169
  - lib/structuraid_core/design_codes/schemas/rc/elastic_modulus_schema.rb
170
+ - lib/structuraid_core/design_codes/schemas/rc/footings/min_height_schema.rb
154
171
  - lib/structuraid_core/design_codes/schemas/rc/footings/punching_shear_capacity_schema.rb
155
172
  - lib/structuraid_core/design_codes/utils/code_requirement.rb
156
173
  - lib/structuraid_core/design_codes/utils/schema_definition.rb
@@ -168,10 +185,11 @@ files:
168
185
  - lib/structuraid_core/engineering/base.rb
169
186
  - lib/structuraid_core/engineering/locations/absolute.rb
170
187
  - lib/structuraid_core/engineering/locations/base.rb
188
+ - lib/structuraid_core/engineering/locations/coordinates_system.rb
171
189
  - lib/structuraid_core/engineering/locations/relative.rb
172
- - lib/structuraid_core/engineering/vector.rb
173
190
  - lib/structuraid_core/errors/base.rb
174
191
  - lib/structuraid_core/errors/design_codes/missing_param_error.rb
192
+ - lib/structuraid_core/errors/design_codes/requirement_not_fulfilled_error.rb
175
193
  - lib/structuraid_core/errors/design_codes/unknown_design_code_error.rb
176
194
  - lib/structuraid_core/errors/design_codes/unrecognized_value_error.rb
177
195
  - lib/structuraid_core/errors/engineering/analysis/section_direction_error.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