civil-tools-v 0.0.1__py3-none-any.whl

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 (50) hide show
  1. CivilTools/DXFGenerator/BasicDXF.py +3 -0
  2. CivilTools/DXFGenerator/__init__.py +0 -0
  3. CivilTools/FigureGenerator/BasicPNGPlotter.py +43 -0
  4. CivilTools/FigureGenerator/BasicPltPlotter.py +3 -0
  5. CivilTools/FigureGenerator/StairCalculationSheetPNGPlotter.py +16 -0
  6. CivilTools/FigureGenerator/__init__.py +0 -0
  7. CivilTools/ReportGenerator/BasicGenerator.py +267 -0
  8. CivilTools/ReportGenerator/DocParagraph.py +17 -0
  9. CivilTools/ReportGenerator/DocPicture.py +9 -0
  10. CivilTools/ReportGenerator/DocTable.py +41 -0
  11. CivilTools/ReportGenerator/SeismicReport.py +220 -0
  12. CivilTools/ReportGenerator/SeismicReportTemplate.py +240 -0
  13. CivilTools/ReportGenerator/StairCalculationReport.py +465 -0
  14. CivilTools/ReportGenerator/UtilFunctions.py +225 -0
  15. CivilTools/ReportGenerator/__init__.py +7 -0
  16. CivilTools/YDBLoader/BuildingDefine/Beam/Beam.py +26 -0
  17. CivilTools/YDBLoader/BuildingDefine/Beam/__init__.py +1 -0
  18. CivilTools/YDBLoader/BuildingDefine/Column/Column.py +16 -0
  19. CivilTools/YDBLoader/BuildingDefine/Column/__init__.py +1 -0
  20. CivilTools/YDBLoader/BuildingDefine/ComponentType.py +10 -0
  21. CivilTools/YDBLoader/BuildingDefine/Geometry/Grid.py +21 -0
  22. CivilTools/YDBLoader/BuildingDefine/Geometry/Joint.py +25 -0
  23. CivilTools/YDBLoader/BuildingDefine/Geometry/StandFloor.py +2 -0
  24. CivilTools/YDBLoader/BuildingDefine/Geometry/__init__.py +3 -0
  25. CivilTools/YDBLoader/BuildingDefine/GlobalResult/BasicResult.py +45 -0
  26. CivilTools/YDBLoader/BuildingDefine/GlobalResult/SeismicResult.py +128 -0
  27. CivilTools/YDBLoader/BuildingDefine/GlobalResult/__init__.py +2 -0
  28. CivilTools/YDBLoader/BuildingDefine/Section/Section.py +49 -0
  29. CivilTools/YDBLoader/BuildingDefine/Section/ShapeEnum.py +42 -0
  30. CivilTools/YDBLoader/BuildingDefine/Section/__init__.py +2 -0
  31. CivilTools/YDBLoader/BuildingDefine/Slab/Slab.py +2 -0
  32. CivilTools/YDBLoader/BuildingDefine/Slab/__init__.py +1 -0
  33. CivilTools/YDBLoader/BuildingDefine/StairPart/LoadDefine.py +38 -0
  34. CivilTools/YDBLoader/BuildingDefine/StairPart/StairComponent.py +95 -0
  35. CivilTools/YDBLoader/BuildingDefine/StairPart/StairPart.py +206 -0
  36. CivilTools/YDBLoader/BuildingDefine/StairPart/__init__.py +3 -0
  37. CivilTools/YDBLoader/BuildingDefine/__init__.py +9 -0
  38. CivilTools/YDBLoader/SQLiteConnector/Connector.py +80 -0
  39. CivilTools/YDBLoader/SQLiteConnector/RowDataFactory.py +45 -0
  40. CivilTools/YDBLoader/SQLiteConnector/YDBTableName.py +96 -0
  41. CivilTools/YDBLoader/SQLiteConnector/__init__.py +3 -0
  42. CivilTools/YDBLoader/YDBLoader.py +224 -0
  43. CivilTools/YDBLoader/YDBType.py +5 -0
  44. CivilTools/YDBLoader/__init__.py +4 -0
  45. CivilTools/__init__.py +1 -0
  46. civil_tools_v-0.0.1.dist-info/LICENSE +21 -0
  47. civil_tools_v-0.0.1.dist-info/METADATA +98 -0
  48. civil_tools_v-0.0.1.dist-info/RECORD +50 -0
  49. civil_tools_v-0.0.1.dist-info/WHEEL +5 -0
  50. civil_tools_v-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ from .BasicGenerator import BasicGenerator, PageSize
2
+ from .SeismicReport import SeismicReport
3
+ from .DocParagraph import DocParagraph
4
+ from .DocTable import DocTable
5
+ from .DocPicture import DocPicture
6
+ from .UtilFunctions import add_comma_in_num_str
7
+ from .StairCalculationReport import StairCalculationReport
@@ -0,0 +1,26 @@
1
+ from ..Section import Section,ShapeEnum
2
+ from ..Geometry import Joint
3
+
4
+ class Beam:
5
+ def __init__(
6
+ self,
7
+ id:int,
8
+ start_joint:Joint,
9
+ end_joint:Joint,
10
+ section:Section
11
+ ):
12
+ self.id = id
13
+ self.start_joint = start_joint
14
+ self.end_joint = end_joint
15
+ self.section = section
16
+ self.std_flr_id = self.start_joint.std_flr_id
17
+
18
+
19
+ def get_data_for_plot(self):
20
+ return [[self.start_joint.x,self.end_joint.x],[self.start_joint.y,self.end_joint.y]]
21
+
22
+ def __str__(self):
23
+ return f"Beam:{self.id}-{str(self.section)}"
24
+
25
+ def __repr__(self):
26
+ return self.__str__()
@@ -0,0 +1 @@
1
+ from .Beam import Beam
@@ -0,0 +1,16 @@
1
+ from ..Section import Section,ShapeEnum
2
+ from ..Geometry import Joint
3
+
4
+ class Column:
5
+ def __init__(self,id:int,joint:Joint,section:Section):
6
+ self.id = id
7
+ self.joint = joint
8
+ self.std_flr_id = joint.std_flr_id
9
+ self.section = section
10
+
11
+
12
+ def __str__(self):
13
+ return f"Column:{self.id}-{str(self.section)}"
14
+
15
+ def __repr__(self):
16
+ return self.__str__()
@@ -0,0 +1 @@
1
+ from .Column import Column
@@ -0,0 +1,10 @@
1
+ from enum import Enum
2
+
3
+ class ComponentType(Enum):
4
+ Beam = 1
5
+ Column = 2
6
+ Wall = 3
7
+ Slab = 4
8
+ Brace = 5
9
+ SlabHole = 6
10
+
@@ -0,0 +1,21 @@
1
+
2
+ from .Joint import Joint
3
+
4
+ class Grid:
5
+ def __init__(
6
+ self,
7
+ id:int,
8
+ s_joint:Joint,
9
+ e_joint:Joint
10
+ ):
11
+ if s_joint.std_flr_id!= e_joint.std_flr_id:
12
+ raise ValueError("The standard-floor-ids of two Joints is not same! " +
13
+ "Please check the data!")
14
+ self.id = id
15
+ self.start_joint = s_joint
16
+ self.end_joint = e_joint
17
+ self.std_flr_id = s_joint.std_flr_id
18
+
19
+ def get_length(self):
20
+ return self.start_joint.distance_to_joint(self.end_joint)
21
+
@@ -0,0 +1,25 @@
1
+ import math
2
+
3
+ class Joint:
4
+ def __init__(self,id:int,x:float,y:float,std_flr_id:int):
5
+ self.id = id
6
+ self.x = x
7
+ self.y = y
8
+ self.std_flr_id = std_flr_id
9
+
10
+ def distance_to_joint(self,other)-> float:
11
+ if not isinstance(other, Joint):
12
+ raise ValueError("Input should be Joint")
13
+ dis_square = (self.x - other.x)**2 + (self.y - other.y)**2
14
+ return math.sqrt(dis_square)
15
+
16
+ def __str__(self):
17
+ return f"Joint(id:{self.id}):[x:{self.x:.4f},y:{self.y:.4f}]:stdFlrId:{self.std_flr_id}"
18
+
19
+ def __repr__(self):
20
+ return str(self)
21
+
22
+
23
+ if __name__ == "__main__":
24
+ j = Joint(1,3.1,36.6513246534313)
25
+ print(j)
@@ -0,0 +1,2 @@
1
+ class StandFloor:
2
+ pass
@@ -0,0 +1,3 @@
1
+ from .Joint import Joint
2
+ from .StandFloor import StandFloor
3
+ from .Grid import Grid
@@ -0,0 +1,45 @@
1
+ from typing import List
2
+
3
+ class SingleMassResult:
4
+ def __init__(self,
5
+ floor_num:int,
6
+ tower_num:int,
7
+ dead_load:float,
8
+ live_load:float,
9
+ slab_area:float,
10
+ ):
11
+ self.floor_num = floor_num
12
+ self.tower_num = tower_num
13
+ self.dead_load = dead_load
14
+ """单层恒载,没有折减"""
15
+ self.live_load = live_load
16
+ """单层活载,没有折减"""
17
+ self.slab_area = slab_area
18
+ """单层楼板面积"""
19
+
20
+ @property
21
+ def mass(self):
22
+ """单层质量,恒+0.5活"""
23
+ return self.dead_load + 0.5 * self.live_load
24
+
25
+ class MassResult:
26
+ def __init__(self, mass_list:List[SingleMassResult]):
27
+ self.mass_list = mass_list
28
+
29
+ @property
30
+ def total_slab_area(self):
31
+ return sum([i.slab_area for i in self.mass_list])
32
+
33
+ @property
34
+ def total_dead_load(self):
35
+ return sum([i.dead_load for i in self.mass_list])
36
+
37
+ @property
38
+ def total_live_load(self):
39
+ return sum([i.live_load for i in self.mass_list])
40
+
41
+ @property
42
+ def total_mass(self):
43
+ return sum([i.mass for i in self.mass_list])
44
+
45
+
@@ -0,0 +1,128 @@
1
+ import math
2
+ import abc
3
+ from typing import List
4
+ import matplotlib.pyplot as plt
5
+
6
+ class SinglePeriod:
7
+ """单个周期
8
+ """
9
+ def __init__(
10
+ self,index:int,
11
+ time:float,
12
+ angle:float = 0,
13
+ coeff_x:float = 1,
14
+ coeff_y:float = 0,
15
+ coeff_z:float = 0,
16
+ mass_particpate_x:float = 0,
17
+ mass_particpate_y:float = 0,
18
+ mass_particpate_z:float = 0,
19
+ ):
20
+ self.index = index
21
+ self.time = time
22
+ self.angle = angle
23
+ assert abs(coeff_x
24
+ + coeff_y
25
+ + coeff_z-1)<0.01 ,"The sum of three participite coeff should == 1"
26
+ self.coeff_x = coeff_x
27
+ self.coeff_y = coeff_y
28
+ self.coeff_z = coeff_z
29
+ self.mass_participate_x = mass_particpate_x
30
+ self.mass_participate_y = mass_particpate_y
31
+ self.mass_participate_z = mass_particpate_z
32
+
33
+ def __str__(self):
34
+ return f"T{self.index}:\t{self.time:.4f}s\t[X:{self.coeff_x*100:.1f}%;\tY:{self.coeff_y*100:.1f}%;\tZ:{self.coeff_z*100:.1f}%]"
35
+
36
+ def __repr__(self):
37
+ return str(self)
38
+
39
+ class Period:
40
+ def __init__(self,periods:List[SinglePeriod] , model_type = None):
41
+ self.periods = periods
42
+
43
+ def __str__(self):
44
+ if len(self.periods)<=10:
45
+ return "\n".join([str(period) for period in self.periods])
46
+ else:
47
+ result = "\n".join([str(period) for period in self.periods[:9]])
48
+ result += "\n....\n"
49
+ result += str(self.periods[-1])
50
+ return result
51
+
52
+ def __repr__(self):
53
+ return self.__str__()
54
+
55
+ class ValuePeer:
56
+ def __init__(self, x:float, y:float):
57
+ self.x = x
58
+ self.y = y
59
+ def __str__(self):
60
+ if self.x >500:
61
+ return f"X:{self.x:.1f}\tY:{self.y:.1f}"
62
+ elif self.x >5:
63
+ return f"X:{self.x:.2f}\tY:{self.y:.2f}"
64
+ else:
65
+ return f"X:{self.x:.3f}\tY:{self.y:.3f}"
66
+
67
+ class FloorSeismicResult:
68
+ def __init__(self,
69
+ floor_num: int,
70
+ tower_num: int,
71
+ force:ValuePeer = None,
72
+ shear:ValuePeer = None,
73
+ moment:ValuePeer = None,
74
+ disp:ValuePeer = None,
75
+ stiffness:ValuePeer = None,
76
+ shear_capacity:ValuePeer = None,
77
+ ):
78
+ self.floor_num = floor_num
79
+ self.tower_num = tower_num
80
+ self.force = force
81
+ self.shear = shear
82
+ self.moment = moment
83
+ self.disp = disp
84
+ self.stiffness = stiffness
85
+ self.shear_capacity = shear_capacity
86
+
87
+ def __str__(self):
88
+ return f"Flr.{self.floor_num}:Fx={self.force.x};Fy={self.force.y}"
89
+
90
+ def __repr__(self):
91
+ return self.__str__()
92
+
93
+ class SeismicResult:
94
+ def __init__(self,
95
+ floor_result : List[FloorSeismicResult]
96
+ ):
97
+ self.floor_result = floor_result
98
+
99
+ @property
100
+ def seismic_shear_x(self):
101
+ return [i.shear.x for i in self.floor_result]
102
+
103
+ @property
104
+ def floor_index(self):
105
+ return [i+1 for i in range(len(self.floor_result))]
106
+
107
+ def plot_shear(self):
108
+ fig,ax = plt.subplots(figsize=(2,5))
109
+ ax.plot(self.seismic_shear_x,self.floor_index)
110
+ return fig,ax
111
+
112
+ def __str__(self):
113
+ result = f"Total floor: {len(self.floor_result)}\n"
114
+ for temp_result in self.floor_result:
115
+ result += str(temp_result)
116
+ result += "\n"
117
+ return result
118
+
119
+ def __repr__(self):
120
+ return self.__str__()
121
+
122
+
123
+ if __name__ == "__main__":
124
+ p_list = []
125
+ for i in range(112):
126
+ p_list.append(SinglePeriod(i+1,i*0.1+0.1,0,1-i*0.1,i*0.1,0))
127
+ P = Period(p_list)
128
+ print(str(P))
@@ -0,0 +1,2 @@
1
+ from .SeismicResult import SinglePeriod, Period, ValuePeer, FloorSeismicResult, SeismicResult
2
+ from .BasicResult import SingleMassResult, MassResult
@@ -0,0 +1,49 @@
1
+ from .ShapeEnum import ShapeEnum
2
+ from typing import List
3
+
4
+ class Section:
5
+ def __init__(self,
6
+ id:int,
7
+ k:ShapeEnum,
8
+ vals:List[float],
9
+ mat:int = 1
10
+ ):
11
+ self.id = id
12
+ self.k = k
13
+ self.mat = mat
14
+ value_number = len(vals)
15
+ self.b = vals[0] if value_number>=1 else None
16
+ self.h = vals[1] if value_number>=2 else None
17
+ self.u = vals[2] if value_number>=3 else None
18
+ self.t = vals[3] if value_number>=4 else None
19
+ self.d = vals[4] if value_number>=5 else None
20
+ self.f = vals[5] if value_number>=6 else None
21
+
22
+
23
+ def __str__(self):
24
+ '''todo:这里需要完善str方法'''
25
+ display_function = {
26
+ ShapeEnum.Rect : lambda : f"Rect-{self.b}mmx{self.h}mm",
27
+ ShapeEnum.HShape : lambda : f"{self.b}",
28
+ ShapeEnum.Circle : lambda : f"Circle-Diameter:{self.b}mm",
29
+ ShapeEnum.RegularPolygon : lambda : f"{self.b}",
30
+ ShapeEnum.Groove : lambda : f"{self.b}",
31
+ ShapeEnum.Cross : lambda : f"{self.b}",
32
+ ShapeEnum.Box : lambda : f"{self.b}",
33
+ ShapeEnum.CircleTube : lambda : f"{self.b}",
34
+ ShapeEnum.CircleCFT : lambda : f"{self.b}",
35
+ ShapeEnum.HSRC : lambda : f"{self.b}",
36
+ ShapeEnum.BoxSRC : lambda : f"{self.b}",
37
+ ShapeEnum.CrossSRC : lambda : f"{self.b}",
38
+
39
+ ShapeEnum.UnKnown : lambda : f"Unknown:{self.b}"
40
+ }
41
+ return display_function[self.k]()
42
+
43
+ def __repr__(self):
44
+ return self.__str__()
45
+
46
+ if __name__ == "__main__":
47
+ s = Section(1,ShapeEnum.Circle,[20,32])
48
+
49
+ print(s)
@@ -0,0 +1,42 @@
1
+ from enum import Enum
2
+ import warnings
3
+ class ShapeEnum(Enum):
4
+ # 矩形
5
+ Rect = 1
6
+ # 工字型
7
+ HShape = 2
8
+ # 圆形
9
+ Circle = 3
10
+ # 正多边形
11
+ RegularPolygon = 4
12
+ # 槽型
13
+ Groove = 5
14
+ # 十字形
15
+ Cross = 6
16
+ # 箱形
17
+ Box = 7
18
+ # 圆管
19
+ CircleTube = 8
20
+ # 钢管混凝土
21
+ CircleCFT = 12
22
+ # 工形劲
23
+ HSRC = 13
24
+ # 箱型劲
25
+ BoxSRC = 14
26
+ # 十字劲
27
+ CrossSRC = 15
28
+
29
+ # 未知截面均归于这个类别
30
+ UnKnown = 999
31
+
32
+ @classmethod
33
+ def ConvertToShapeEnum(cls,index:int):
34
+ try:
35
+ return (ShapeEnum)(index)
36
+ except ValueError:
37
+ warnings.warn(f"Shape kind ${index} is not supported yet. It will be converted to UnKnown.")
38
+ return ShapeEnum.UnKnown
39
+
40
+
41
+
42
+
@@ -0,0 +1,2 @@
1
+ from .Section import Section
2
+ from .ShapeEnum import ShapeEnum
@@ -0,0 +1,2 @@
1
+ class Slab:
2
+ pass
@@ -0,0 +1 @@
1
+ from .Slab import Slab
@@ -0,0 +1,38 @@
1
+ from enum import Enum
2
+
3
+ class LoadParams:
4
+ def __init__(self):
5
+ self.append_dead_load = 1
6
+ self.live_load = 3.5
7
+ self.dead_load_coef = 1.3
8
+ self.live_load_coef = 1.5
9
+ self.live_load_adjust_coef = 1
10
+ self.live_load_permenent_coef = 0.5
11
+
12
+ class LoadType(Enum):
13
+ Dead = 1
14
+ Live = 2
15
+
16
+ class LoadCalulateType(Enum):
17
+ qk = 1
18
+ q = 2
19
+ qe = 3
20
+
21
+ class StairLoad:
22
+ def __init__(self, dead, live, load_params:LoadParams):
23
+ self.dead = dead
24
+ self.live = live
25
+ self.load_params = load_params
26
+
27
+ @property
28
+ def qk(self):
29
+ return self.dead + self.live
30
+
31
+ @property
32
+ def q(self):
33
+ return self.load_params.dead_load_coef* self.dead +self.load_params.live_load_coef* self.live
34
+
35
+ @property
36
+ def qe(self):
37
+ return self.dead + self.load_params.live_load_permenent_coef* self.live
38
+
@@ -0,0 +1,95 @@
1
+ import math
2
+ import numpy as np
3
+
4
+ class Component:
5
+
6
+ def init_attr(self):
7
+ self.E = 30000
8
+ self.B = 1000
9
+ self.H = 150
10
+ self.vertical_q = 10
11
+ self.length = math.sqrt((self.end_point[1] - self.start_point[1])**2 + (self.end_point[0] - self.start_point[0])**2)
12
+ if self.start_point[0] == self.end_point[0]:
13
+ self.alpha = 0
14
+ else:
15
+ self.alpha = math.atan((self.end_point[1] - self.start_point[1]) / (self.end_point[0] - self.start_point[0]))
16
+
17
+ def __init__(self,p1,p2) -> None:
18
+ self.start_point = p1
19
+ self.end_point = p2
20
+ self.section_kind = "Rectangle"
21
+ self.init_attr()
22
+
23
+ def set_comp_attr(self,e,b,h):
24
+ self.E = e
25
+ self.B = b
26
+ self.H = h
27
+
28
+ def set_vertical_q(self, q):
29
+ self.vertical_q = q
30
+
31
+ def create_k(self):
32
+ self.calculate_section_attr()
33
+ K = np.zeros((6,6))
34
+
35
+ l = self.length
36
+ i = self.E *self.I / l
37
+ B = self.E *self.area / l
38
+ c_x = math.cos(self.alpha)
39
+ c_y = math.sin(self.alpha)
40
+ a1 = B * c_x * c_x + 12 * i / l / l * c_y * c_y
41
+ a2 = (B - 12 * i / l / l) * c_x * c_y
42
+ a3 = B * c_y * c_y + 12 * i / l / l * c_x * c_x
43
+ a4 = -6 * i / l * c_y
44
+ a5 = 6 * i / l * c_x
45
+ a6 = 4 * i
46
+ K[0, 0] = K[3, 3] = a1
47
+ K[0, 3] = K[3, 0] = -a1
48
+ K[1, 0] = K[4, 3] = K[0, 1] = K[3, 4] = a2
49
+ K[1, 3] = K[0, 4] = K[3, 1] = K[4, 0] = -a2
50
+ K[1, 1] = K[4, 4] = a3
51
+ K[1, 4] = K[4, 1] = -a3
52
+ K[0, 2] = K[0, 5] = K[2, 0] = K[5, 0] = a4
53
+ K[2, 3] = K[3, 5] = K[3, 2] = K[5, 3] = -a4
54
+ K[1, 2] = K[1, 5] = K[2, 1] = K[5, 1] = a5
55
+ K[2, 4] = K[4, 5] = K[4, 2] = K[5, 4] = -a5
56
+ K[2, 2] = K[5, 5] = a6
57
+ K[2, 5] = K[5, 2] = a6 / 2
58
+ return K
59
+
60
+ def create_f(self):
61
+ F = np.zeros((6,1))
62
+ # 这里只针对竖向荷载
63
+ length = abs(self.end_point[0] - self.start_point[0])
64
+
65
+ F[1,0] = -self.vertical_q * length / 2
66
+ F[2,0] = -self.vertical_q * length ** 2 / 12
67
+ F[4,0] = -self.vertical_q * length / 2
68
+ F[5,0] = self.vertical_q * length ** 2 / 12
69
+ return F
70
+
71
+ def calculate_section_attr(self):
72
+ if self.section_kind == "Rectangle":
73
+ self.I = self.B * self.H **3 / 12
74
+ self.area = self.B * self.H
75
+
76
+
77
+ def set_f(self,f_1_x,f_1_y,f_2_x,f_2_y):
78
+ self.f_1_x = f_1_x/1e3
79
+ self.f_1_y = f_1_y/1e3
80
+ self.f_2_x = f_2_x/1e3
81
+ self.f_2_y = f_2_y/1e3
82
+
83
+ def set_m(self, m_1, m_2):
84
+ self.m_1 = m_1/1e6
85
+ self.m_2 = m_2/1e6
86
+
87
+
88
+ @property
89
+ def v1(self):
90
+ return self.f_1_y*np.cos(self.alpha) - self.f_1_x*np.sin(self.alpha)
91
+
92
+ @property
93
+ def v2(self):
94
+ return -self.f_2_y*np.cos(self.alpha) + self.f_2_x*np.sin(self.alpha)
95
+