midas-civil 0.0.9__tar.gz → 0.1.1__tar.gz

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.

Potentially problematic release.


This version of midas-civil might be problematic. Click here for more details.

Files changed (31) hide show
  1. {midas_civil-0.0.9 → midas_civil-0.1.1}/PKG-INFO +1 -1
  2. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/__init__.py +6 -4
  3. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_boundary.py +8 -2
  4. midas_civil-0.1.1/midas_civil/_construction.py +419 -0
  5. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_element.py +43 -14
  6. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_group.py +22 -1
  7. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_load.py +325 -2
  8. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_material.py +10 -10
  9. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_model.py +38 -0
  10. midas_civil-0.1.1/midas_civil/_result.py +155 -0
  11. midas_civil-0.1.1/midas_civil/_result_extract.py +193 -0
  12. midas_civil-0.1.1/midas_civil/_temperature.py +353 -0
  13. midas_civil-0.1.1/midas_civil/_tendon.py +204 -0
  14. midas_civil-0.1.1/midas_civil/_view.py +26 -0
  15. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil.egg-info/PKG-INFO +1 -1
  16. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil.egg-info/SOURCES.txt +5 -0
  17. {midas_civil-0.0.9 → midas_civil-0.1.1}/setup.py +1 -1
  18. midas_civil-0.0.9/midas_civil/_result_extract.py +0 -103
  19. {midas_civil-0.0.9 → midas_civil-0.1.1}/LICENSE +0 -0
  20. {midas_civil-0.0.9 → midas_civil-0.1.1}/README.md +0 -0
  21. /midas_civil-0.0.9/midas_civil/_construction.py → /midas_civil-0.1.1/midas_civil/_construction_backup.py +0 -0
  22. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_mapi.py +0 -0
  23. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_node.py +0 -0
  24. /midas_civil-0.0.9/midas_civil/_result.py → /midas_civil-0.1.1/midas_civil/_result copy.py +0 -0
  25. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_section.py +0 -0
  26. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_thickness.py +0 -0
  27. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil/_utils.py +0 -0
  28. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil.egg-info/dependency_links.txt +0 -0
  29. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil.egg-info/requires.txt +0 -0
  30. {midas_civil-0.0.9 → midas_civil-0.1.1}/midas_civil.egg-info/top_level.txt +0 -0
  31. {midas_civil-0.0.9 → midas_civil-0.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: midas_civil
3
- Version: 0.0.9
3
+ Version: 0.1.1
4
4
  Summary: Python library for MIDAS Civil NX
5
5
  Author: Sumit Shekhar
6
6
  Author-email: sumit.midasit@gmail.com
@@ -1,24 +1,26 @@
1
1
  from ._mapi import *
2
2
  from ._model import *
3
3
  from ._boundary import *
4
- # from .section import *
5
4
  from ._utils import *
6
5
  from ._node import *
7
6
  from ._element import *
8
7
  from ._load import *
9
8
  from ._group import *
10
- from ._result_extract import *
9
+ from ._result import *
11
10
 
12
11
  #--- TESTING IMPORTS ---
13
12
  from ._material import *
14
13
  from ._section import *
15
- # from .element_new import *
16
14
 
17
15
  from ._result_extract import *
18
16
  from ._construction import *
19
17
  from ._thickness import *
18
+ from ._temperature import *
19
+
20
+ from ._tendon import *
21
+ from ._view import *
20
22
 
21
23
  print('')
22
- print('*'*20,' MIDAS CIVIL-NX PYTHON LIBRARY 🐍 ','*'*20)
24
+ print('*'*20,' MIDAS CIVIL-NX PYTHON LIBRARY 🐍 ','*'*20)
23
25
  print('')
24
26
 
@@ -10,7 +10,6 @@ def convList(item):
10
10
  return item
11
11
 
12
12
 
13
-
14
13
  class Boundary:
15
14
 
16
15
  @classmethod
@@ -55,7 +54,14 @@ class Boundary:
55
54
  if len(constraint) > 7: constraint = constraint[:7]
56
55
  string = ''.join(['1' if char != '0' else '0' for char in constraint])
57
56
 
58
-
57
+ # Check if group exists, create if not
58
+ if group != "":
59
+ chk = 0
60
+ a = [v['NAME'] for v in Group.Boundary.json()["Assign"].values()]
61
+ if group in a:
62
+ chk = 1
63
+ if chk == 0:
64
+ Group.Boundary(group)
59
65
 
60
66
  self.NODE = node
61
67
  self.CONST = string
@@ -0,0 +1,419 @@
1
+ from ._mapi import *
2
+
3
+ class CS:
4
+
5
+
6
+ class STAGE:
7
+ stages = []
8
+
9
+ def __init__(self,
10
+ name: str,
11
+ duration: float = 0,
12
+ s_group: str = None,
13
+ s_age: float = None,
14
+ s_type: str= None,
15
+ b_group: str = None,
16
+ b_pos: str = None,
17
+ b_type: str = None,
18
+ l_group: str = None,
19
+ l_day: str = None,
20
+ l_type: str = None,
21
+ id: int = None,
22
+ sv_result: bool = True,
23
+ sv_step: bool = False,
24
+ load_in: bool = False,
25
+ nl: int = 5,
26
+ addstp: list = None):
27
+ """
28
+ Construction Stage define.
29
+
30
+ Parameters:
31
+ name: Name of Construction Stage
32
+ duration: Duration of Construction Stage in days (default 0)
33
+ s_group: Structure group name or list of group names (default None)
34
+ s_age: Age of structure group in days and Redistribution value(%) win case of Deactivation (default 0)
35
+ s_type: Structure activation type - "A" to activate, "D" to deactivate(default A)
36
+ b_group: Boundary group name or list of group names (default None)
37
+ b_pos: Boundary position type - "ORIGINAL" or "DEFORMED", or list (default DEFORMED)
38
+ b_type: Boundary activation type - "A" to activate, "D" to deactivate (default A)
39
+ l_group: Load group name or list of group names (default None)
40
+ l_day: Load activation day - "FIRST" or "LAST" (default "FIRST")
41
+ l_type: Load activation type - "A" to activate, "D" to deactivate (default A)
42
+ id: The construction stage ID (optional)
43
+ sv_result: Save results of this stage (default True)
44
+ sv_step: Add additional step results (default False)
45
+ load_in: Load incremental steps for material nonlinear analysis (default False)
46
+ nl: Number of load incremental steps (default 5)
47
+ addstp: List of additional steps (default None)
48
+
49
+ Examples:
50
+ ```python
51
+ # Single group activation
52
+ CS("CS1", 7, "S1", 7, "A", "B1", "DEFORMED", "A", "L1", "FIRST", "A")
53
+
54
+ # Multiple group activation
55
+ CS("CS1", 7, ["S1", "S2"], [7, 10], ["A", "A"], ["B1", "B2"],
56
+ ["DEFORMED", "DEFORMED"], ["A", "A"], ["L1", "L2"], ["FIRST", "FIRST"], ["A", "A"])
57
+
58
+ # Mixed activation and deactivation
59
+ CS("CS1", 7, ["S1", "S2"], [7, 10], ["A", "D"], ["B1", "B2"],
60
+ ["DEFORMED", "DEFORMED"], ["A", "D"], "L1", "FIRST", "A")
61
+
62
+ # With additional options
63
+ CS("CS1", 7, "S1", 7, "A", "B1", "DEFORMED", "A", "L1", "FIRST", "A",
64
+ sv_result=True, sv_step=True, load_in=True, nl=6, addstp=[1, 2, 3])
65
+ ```
66
+ """
67
+
68
+ self.NAME = name
69
+ self.DURATION = duration
70
+ self.SV_Result = sv_result
71
+ self.SV_Step = sv_step
72
+ self.Load_IN = load_in
73
+ self.NL = nl
74
+ self.addstp = [] if addstp is None else addstp
75
+
76
+ # Initialize group containers
77
+ self.act_structure_groups = []
78
+ self.deact_structure_groups = []
79
+ self.act_boundary_groups = []
80
+ self.deact_boundary_groups = []
81
+ self.act_load_groups = []
82
+ self.deact_load_groups = []
83
+
84
+
85
+ # Set ID
86
+ if id is None:
87
+ self.ID = len(CS.STAGE.stages) + 1
88
+ else:
89
+ self.ID = id
90
+
91
+
92
+ # Process structure groups
93
+ if s_group:
94
+ # Convert single values to lists for uniform processing
95
+ if not isinstance(s_group, list):
96
+ s_group = [s_group]
97
+ s_age = [s_age if s_age is not None else 0]
98
+ s_type = [s_type if s_type is not None else "A"]
99
+ else:
100
+ # Ensure other parameters are lists too
101
+ if s_age is None:
102
+ s_age = [0] * len(s_group)
103
+ elif not isinstance(s_age, list):
104
+ s_age = [s_age] * len(s_group)
105
+
106
+ if s_type is None:
107
+ s_type = ["A"] * len(s_group)
108
+ elif not isinstance(s_type, list):
109
+ s_type = [s_type] * len(s_group)
110
+
111
+ # Process each structure group
112
+ for i, group in enumerate(s_group):
113
+ if i < len(s_type) and s_type[i] == "A":
114
+ # Activation: Check if already activated in previous stages
115
+ for stage in CS.STAGE.stages:
116
+ for existing_group in stage.act_structure_groups:
117
+ if existing_group["name"] == group:
118
+ raise ValueError(f"Structure group '{group}' has already been activated in stage '{stage.NAME}' (ID: {stage.ID})")
119
+
120
+ age = s_age[i] if i < len(s_age) else 0
121
+ self.act_structure_groups.append({"name": group, "age": age})
122
+ else:
123
+ # Deactivation: Check if activated in previous stages
124
+ activated = False
125
+ for stage in CS.STAGE.stages:
126
+ for existing_group in stage.act_structure_groups:
127
+ if existing_group["name"] == group:
128
+ activated = True
129
+ break
130
+ if activated:
131
+ break
132
+
133
+ if not activated:
134
+ raise ValueError(f"Structure group '{group}' cannot be deactivated as it has not been activated in any previous stage")
135
+
136
+ # For deactivation, s_age value is used as redist percentage
137
+ redist = s_age[i] if i < len(s_age) else 100
138
+ self.deact_structure_groups.append({"name": group, "redist": redist})
139
+
140
+ # Process boundary groups
141
+ if b_group:
142
+ # Convert single values to lists for uniform processing
143
+ if not isinstance(b_group, list):
144
+ b_group = [b_group]
145
+ b_pos = [b_pos if b_pos is not None else "DEFORMED"]
146
+ b_type = [b_type if b_type is not None else "A"]
147
+ else:
148
+ # Ensure other parameters are lists too
149
+ if b_pos is None:
150
+ b_pos = ["DEFORMED"] * len(b_group)
151
+ elif not isinstance(b_pos, list):
152
+ b_pos = [b_pos] * len(b_group)
153
+
154
+ if b_type is None:
155
+ b_type = ["A"] * len(b_group)
156
+ elif not isinstance(b_type, list):
157
+ b_type = [b_type] * len(b_group)
158
+
159
+ # Process each boundary group
160
+ for i, group in enumerate(b_group):
161
+ if i < len(b_type) and b_type[i] == "A":
162
+ # Activation: Check if already activated in previous stages
163
+ for stage in CS.STAGE.stages:
164
+ for existing_group in stage.act_boundary_groups:
165
+ if existing_group["name"] == group:
166
+ raise ValueError(f"Boundary group '{group}' has already been activated in stage '{stage.NAME}' (ID: {stage.ID})")
167
+
168
+ pos = b_pos[i] if i < len(b_pos) else "DEFORMED"
169
+ self.act_boundary_groups.append({"name": group, "pos": pos})
170
+ else:
171
+ # Deactivation: Check if activated in previous stages
172
+ activated = False
173
+ for stage in CS.STAGE.stages:
174
+ for existing_group in stage.act_boundary_groups:
175
+ if existing_group["name"] == group:
176
+ activated = True
177
+ break
178
+ if activated:
179
+ break
180
+
181
+ if not activated:
182
+ raise ValueError(f"Boundary group '{group}' cannot be deactivated as it has not been activated in any previous stage")
183
+
184
+ self.deact_boundary_groups.append(group)
185
+
186
+ # Process load groups
187
+ if l_group:
188
+ # Convert single values to lists for uniform processing
189
+ if not isinstance(l_group, list):
190
+ l_group = [l_group]
191
+ l_day = [l_day if l_day is not None else "FIRST"]
192
+ l_type = [l_type if l_type is not None else "A"]
193
+ else:
194
+ # Ensure other parameters are lists too
195
+ if l_day is None:
196
+ l_day = ["FIRST"] * len(l_group)
197
+ elif not isinstance(l_day, list):
198
+ l_day = [l_day] * len(l_group)
199
+
200
+ if l_type is None:
201
+ l_type = ["A"] * len(l_group)
202
+ elif not isinstance(l_type, list):
203
+ l_type = [l_type] * len(l_group)
204
+
205
+ # Process each load group
206
+ for i, group in enumerate(l_group):
207
+ if i < len(l_type) and l_type[i] == "A":
208
+ # Activation: Check if already activated in previous stages
209
+ for stage in CS.STAGE.stages:
210
+ for existing_group in stage.act_load_groups:
211
+ if existing_group["name"] == group:
212
+ raise ValueError(f"Load group '{group}' has already been activated in stage '{stage.NAME}' (ID: {stage.ID})")
213
+
214
+ day = l_day[i] if i < len(l_day) else "FIRST"
215
+ self.act_load_groups.append({"name": group, "day": day})
216
+ else:
217
+ # Deactivation: Check if activated in previous stages
218
+ activated = False
219
+ for stage in CS.STAGE.stages:
220
+ for existing_group in stage.act_load_groups:
221
+ if existing_group["name"] == group:
222
+ activated = True
223
+ break
224
+ if activated:
225
+ break
226
+
227
+ if not activated:
228
+ raise ValueError(f"Load group '{group}' cannot be deactivated as it has not been activated in any previous stage")
229
+
230
+ day = l_day[i] if i < len(l_day) else "FIRST"
231
+ self.deact_load_groups.append({"name": group, "day": day})
232
+
233
+ CS.STAGE.stages.append(self)
234
+
235
+ @classmethod
236
+ def json(cls):
237
+ """
238
+ Converts Construction Stage data to JSON format
239
+ Example:
240
+ # Get the JSON data for all construction stages
241
+ json_data = CS.json()
242
+ print(json_data)
243
+ """
244
+ json = {"Assign": {}}
245
+
246
+ for csa in cls.stages:
247
+ stage_data = {
248
+ "NAME": csa.NAME,
249
+ "DURATION": csa.DURATION,
250
+ "bSV_RSLT": csa.SV_Result,
251
+ "bSV_STEP": csa.SV_Step,
252
+ "bLOAD_STEP": csa.Load_IN
253
+ }
254
+
255
+ # Add incremental steps if load step is enabled
256
+ if csa.Load_IN:
257
+ stage_data["INCRE_STEP"] = csa.NL
258
+
259
+ # Add additional steps if specified
260
+ if csa.addstp:
261
+ stage_data["ADD_STEP"] = csa.addstp
262
+ else:
263
+ stage_data["ADD_STEP"] = []
264
+
265
+ # Handle structure group activation
266
+ if csa.act_structure_groups:
267
+ stage_data["ACT_ELEM"] = []
268
+ for group in csa.act_structure_groups:
269
+ stage_data["ACT_ELEM"].append({
270
+ "GRUP_NAME": group["name"],
271
+ "AGE": group["age"]
272
+ })
273
+
274
+ # Handle structure group deactivation
275
+ if csa.deact_structure_groups:
276
+ stage_data["DACT_ELEM"] = []
277
+ for group in csa.deact_structure_groups:
278
+ stage_data["DACT_ELEM"].append({
279
+ "GRUP_NAME": group["name"],
280
+ "REDIST": group["redist"]
281
+ })
282
+
283
+ # Handle boundary group activation
284
+ if csa.act_boundary_groups:
285
+ stage_data["ACT_BNGR"] = []
286
+ for group in csa.act_boundary_groups:
287
+ stage_data["ACT_BNGR"].append({
288
+ "BNGR_NAME": group["name"],
289
+ "POS": group["pos"]
290
+ })
291
+
292
+ # Handle boundary group deactivation
293
+ if csa.deact_boundary_groups:
294
+ stage_data["DACT_BNGR"] = []
295
+ for group_name in csa.deact_boundary_groups:
296
+ stage_data["DACT_BNGR"].append(group_name)
297
+
298
+ # Handle load group activation
299
+ if csa.act_load_groups:
300
+ stage_data["ACT_LOAD"] = []
301
+ for group in csa.act_load_groups:
302
+ stage_data["ACT_LOAD"].append({
303
+ "LOAD_NAME": group["name"],
304
+ "DAY": group["day"]
305
+ })
306
+
307
+ # Handle load group deactivation
308
+ if csa.deact_load_groups:
309
+ stage_data["DACT_LOAD"] = []
310
+ for group in csa.deact_load_groups:
311
+ stage_data["DACT_LOAD"].append({
312
+ "LOAD_NAME": group["name"],
313
+ "DAY": group["day"]
314
+ })
315
+
316
+ json["Assign"][str(csa.ID)] = stage_data
317
+
318
+ return json
319
+
320
+ @classmethod
321
+ def create(cls):
322
+ """Creates construction stages in the database"""
323
+ MidasAPI("PUT", "/db/stag", cls.json())
324
+
325
+ @classmethod
326
+ def get(cls):
327
+ """Gets construction stage data from the database"""
328
+ return MidasAPI("GET", "/db/stag")
329
+
330
+ @classmethod
331
+ def sync(cls):
332
+ """Updates the CS class with data from the database"""
333
+ cls.stages = []
334
+ a = cls.get()
335
+ if a != {'message': ''}:
336
+ if "STAG" in a:
337
+ stag_data_dict = a["STAG"]
338
+ else:
339
+ return
340
+
341
+ for stag_id, stag_data in stag_data_dict.items():
342
+ # Basic stage data
343
+ name = stag_data.get("NAME")
344
+ duration = stag_data.get("DURATION")
345
+ sv_result = stag_data.get("bSV_RSLT")
346
+ sv_step = stag_data.get("bSV_STEP")
347
+ load_in = stag_data.get("bLOAD_STEP")
348
+ nl = stag_data.get("INCRE_STEP")
349
+ addstp = stag_data.get("ADD_STEP")
350
+
351
+ # Create a new CS object with basic properties
352
+ new_cs = CS.STAGE(
353
+ name=name,
354
+ duration=duration,
355
+ id=int(stag_id),
356
+ sv_result=sv_result,
357
+ sv_step=sv_step,
358
+ load_in=load_in,
359
+ nl=nl,
360
+ addstp=addstp
361
+ )
362
+
363
+ CS.STAGE.stages.pop()
364
+
365
+ # Process activation elements
366
+ if "ACT_ELEM" in stag_data and stag_data["ACT_ELEM"]:
367
+ for elem in stag_data["ACT_ELEM"]:
368
+ group_name = elem.get("GRUP_NAME")
369
+ age = elem.get("AGE")
370
+ new_cs.act_structure_groups.append({"name": group_name, "age": age})
371
+
372
+ # Process deactivation elements
373
+ if "DACT_ELEM" in stag_data and stag_data["DACT_ELEM"]:
374
+ for elem in stag_data["DACT_ELEM"]:
375
+ if isinstance(elem, dict):
376
+ group_name = elem.get("GRUP_NAME")
377
+ redist = elem.get("REDIST")
378
+ else:
379
+ group_name = elem
380
+ redist = 0
381
+ new_cs.deact_structure_groups.append({"name": group_name, "redist": redist})
382
+
383
+ # Process activation boundary groups
384
+ if "ACT_BNGR" in stag_data and stag_data["ACT_BNGR"]:
385
+ for bngr in stag_data["ACT_BNGR"]:
386
+ group_name = bngr.get("BNGR_NAME")
387
+ pos = bngr.get("POS")
388
+ new_cs.act_boundary_groups.append({"name": group_name, "pos": pos})
389
+
390
+ # Process deactivation boundary groups
391
+ if "DACT_BNGR" in stag_data and stag_data["DACT_BNGR"]:
392
+ for bngr in stag_data["DACT_BNGR"]:
393
+ new_cs.deact_boundary_groups.append(bngr)
394
+
395
+ # Process activation loads
396
+ if "ACT_LOAD" in stag_data and stag_data["ACT_LOAD"]:
397
+ for load in stag_data["ACT_LOAD"]:
398
+ group_name = load.get("LOAD_NAME")
399
+ day = load.get("DAY")
400
+ new_cs.act_load_groups.append({"name": group_name, "day": day})
401
+
402
+ # Process deactivation loads
403
+ if "DACT_LOAD" in stag_data and stag_data["DACT_LOAD"]:
404
+ for load in stag_data["DACT_LOAD"]:
405
+ if isinstance(load, dict):
406
+ group_name = load.get("LOAD_NAME")
407
+ day = load.get("DAY")
408
+ else:
409
+ group_name = load
410
+ day = "FIRST"
411
+ new_cs.deact_load_groups.append({"name": group_name, "day": day})
412
+
413
+ CS.STAGE.stages.append(new_cs)
414
+
415
+ @classmethod
416
+ def delete(cls):
417
+ """Deletes all construction stages from the database and resets the class"""
418
+ cls.stages = []
419
+ return MidasAPI("DELETE", "/db/stag")