• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

haiiliin / abqpy / 9778482350

03 Jul 2024 01:08PM UTC coverage: 73.879%. First build
9778482350

Pull #5647

github

web-flow
Merge 269283162 into f63af1053
Pull Request #5647: [bugfix] Move circular imports to `TYPE_CHECKING` blocks (backport #5586)

17 of 23 new or added lines in 6 files covered. (73.91%)

24341 of 32947 relevant lines covered (73.88%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.37
/src/abaqus/Model/ModelBase.py
1
from __future__ import annotations
1✔
2

3
from typing import TYPE_CHECKING
1✔
4

5
from typing_extensions import Literal
1✔
6

7
from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
1✔
8

9
from ..Adaptivity.AdaptiveMeshConstraint import AdaptiveMeshConstraint
1✔
10
from ..Adaptivity.AdaptiveMeshControl import AdaptiveMeshControl
1✔
11
from ..Adaptivity.RemeshingRule import RemeshingRule
1✔
12
from ..Amplitude.Amplitude import Amplitude
1✔
13
from ..BeamSectionProfile.Profile import Profile
1✔
14
from ..BoundaryCondition.BoundaryCondition import BoundaryCondition
1✔
15
from ..Calibration.Calibration import Calibration
1✔
16
from ..Constraint.Constraint import Constraint
1✔
17
from ..Feature.FeatureOptions import FeatureOptions
1✔
18
from ..Field.AnalyticalField import AnalyticalField
1✔
19
from ..Field.DiscreteField import DiscreteField
1✔
20
from ..Filter.Filter import Filter
1✔
21
from ..Interaction.ContactControl import ContactControl
1✔
22
from ..Interaction.ContactInitialization import ContactInitialization
1✔
23
from ..Interaction.ContactProperty import ContactProperty
1✔
24
from ..Interaction.ContactStabilization import ContactStabilization
1✔
25
from ..Interaction.Interaction import Interaction
1✔
26
from ..Load.Load import Load
1✔
27
from ..Material.Material import Material
1✔
28
from ..Optimization.OptimizationTask import OptimizationTask
1✔
29
from ..Part.Part import Part
1✔
30
from ..PredefinedField.PredefinedField import PredefinedField
1✔
31
from ..Section.Section import Section
1✔
32
from ..Sketcher.ConstrainedSketch import ConstrainedSketch
1✔
33
from ..Step.InitialStep import InitialStep
1✔
34
from ..Step.Step import Step
1✔
35
from ..StepOutput.FieldOutputRequest import FieldOutputRequest
1✔
36
from ..StepOutput.HistoryOutputRequest import HistoryOutputRequest
1✔
37
from ..StepOutput.IntegratedOutputSection import IntegratedOutputSection
1✔
38
from ..StepOutput.TimePoint import TimePoint
1✔
39
from ..UtilityAndView.abaqusConstants import (
1✔
40
    B31,
41
    C3D8I,
42
    C3D10,
43
    NOT_SET,
44
    OFF,
45
    ON,
46
    PRESERVE_SECTION,
47
    S4,
48
    STANDARD_EXPLICIT,
49
    Boolean,
50
    SymbolicConstant,
51
)
52
from ..UtilityAndView.abaqusConstants import abaqusConstants as C
1✔
53
from .KeywordBlock import KeywordBlock
1✔
54

55
if TYPE_CHECKING:
1✔
NEW
56
    from ..Assembly.Assembly import Assembly
×
57

58

59
@abaqus_class_doc
1✔
60
class ModelBase:
1✔
61
    """Abaqus creates a Model object named `Model-1` when a session is started.
62

63
    .. note::
64
        This object can be accessed by::
65

66
            mdb.models[name]
67

68
        The corresponding analysis keywords are:
69

70
        - PHYSICAL CONSTANTS
71
    """
72

73
    #: A String specifying the repository key.
74
    name: str = ""
1✔
75

76
    #: None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
77
    stefanBoltzmann: float | None = None
1✔
78

79
    #: None or a Float specifying the absolute zero constant. The default value is None.
80
    absoluteZero: float | None = None
1✔
81

82
    #: A SymbolicConstant specifying the type of incident wave formulation to be used in
83
    #: acoustic problems. Possible values are NOT_SET, SCATTERED, and TOTAL. The default value
84
    #: is NOT_SET.
85
    waveFormulation: SymbolicConstant = NOT_SET
1✔
86

87
    #: None or a Float specifying the universal gas constant. The default value is None.
88
    universalGas: float | None = None
1✔
89

90
    #: A Boolean specifying whether an input file should be written without parts and
91
    #: assemblies. The default value is OFF.
92
    noPartsInputFile: Boolean = OFF
1✔
93

94
    #: An Int specifying the increment, interval, iteration or cycle where the restart analysis
95
    #: will start. To select the end of the step use the SymbolicConstant STEP_END.
96
    restartIncrement: int | SymbolicConstant
1✔
97

98
    #: A Boolean specifying that the step specified by **restartStep** should be terminated at
99
    #: the increment specified by **restartIncrement**.
100
    endRestartStep: Boolean = OFF
1✔
101

102
    #: A Boolean specifying that a shell global model drives a solid submodel.
103
    shellToSolid: Boolean = OFF
1✔
104

105
    #: A Float specifying the time stamp that indicates when the model was last changed.
106
    lastChangedCount: float | None = None
1✔
107

108
    #: A String specifying the purpose and contents of the Model object. The default value is
109
    #: an empty string.
110
    description: str = ""
1✔
111

112
    #: A String specifying the name of the job that generated the restart data.
113
    restartJob: str = ""
1✔
114

115
    #: A String specifying the name of the step where the restart analysis will start.
116
    restartStep: str = ""
1✔
117

118
    #: A String specifying the name of the job that generated the results for the global model.
119
    globalJob: str = ""
1✔
120

121
    #: A boolean specifying the status of constraints created in a model, in the model which
122
    #: instances this model.
123
    copyConstraints: Boolean = OFF
1✔
124

125
    #: A boolean specifying the status of connectors created in a model, in the model which
126
    #: instances this model.
127
    copyConnectors: Boolean = OFF
1✔
128

129
    #: A boolean specifying the status of interactions created in a model, in the model which
130
    #: instances this model.
131
    copyInteractions: Boolean = OFF
1✔
132

133
    #: A KeywordBlock object.
134
    keywordBlock: KeywordBlock = KeywordBlock()
1✔
135

136
    #: An Assembly object.
137
    rootAssembly: Assembly
1✔
138

139
    #: A repository of Amplitude objects.
140
    amplitudes: dict[str, Amplitude] = {}
1✔
141

142
    #: A repository of Profile objects.
143
    profiles: dict[str, Profile] = {}
1✔
144

145
    #: A repository of BoundaryCondition objects.
146
    boundaryConditions: dict[str, BoundaryCondition] = {}
1✔
147

148
    #: A repository of ConstrainedSketchConstraint objects.
149
    constraints: dict[str, Constraint] = {}
1✔
150

151
    #: A repository of AnalyticalField objects.
152
    analyticalFields: dict[str, AnalyticalField] = {}
1✔
153

154
    #: A repository of DiscreteField objects.
155
    discreteFields: dict[str, DiscreteField] = {}
1✔
156

157
    #: A repository of PredefinedField objects.
158
    predefinedFields: dict[str, PredefinedField] = {}
1✔
159

160
    #: A repository of Interaction objects.
161
    interactions: dict[str, Interaction] = {}
1✔
162

163
    #: A repository of InteractionProperty objects.
164
    interactionProperties: dict[str, ContactProperty] = {}
1✔
165

166
    #: A repository of ContactControl objects.
167
    contactControls: dict[str, ContactControl] = {}
1✔
168

169
    #: A repository of ContactInitialization objects.
170
    contactInitializations: dict[str, ContactInitialization] = {}
1✔
171

172
    #: A repository of ContactStabilization objects.
173
    contactStabilizations: dict[str, ContactStabilization] = {}
1✔
174

175
    #: A tuple of tuples of Strings specifying the linked child PartInstance name in the
176
    #: current model to the corresponding parent PartInstance name in a different model.
177
    linkedInstances: tuple = ()
1✔
178

179
    #: A tuple of tuples of Strings specifying the linked child Part name in the current model
180
    #: to the corresponding parent Part name in a different model.
181
    linkedParts: tuple = ()
1✔
182

183
    #: A repository of Load objects.
184
    loads: dict[str, Load] = {}
1✔
185

186
    #: A repository of Material objects.
187
    materials: dict[str, Material] = {}
1✔
188

189
    #: A repository of Calibration objects.
190
    calibrations: dict[str, Calibration] = {}
1✔
191

192
    #: A repository of Section objects.
193
    sections: dict[str, Section] = {}
1✔
194

195
    #: A repository of RemeshingRule objects.
196
    remeshingRules: dict[str, RemeshingRule] = {}
1✔
197

198
    #: A repository of ConstrainedSketch objects.
199
    sketches: dict[str, ConstrainedSketch] = {}
1✔
200

201
    #: A repository of Part objects.
202
    parts: dict[str, Part] = {}
1✔
203

204
    #: A repository of Step objects.
205
    steps: dict[str, Step] = {}
1✔
206

207
    #: A FeatureOptions object.
208
    featureOptions: FeatureOptions = FeatureOptions()
1✔
209

210
    #: A repository of AdaptiveMeshConstraint objects.
211
    adaptiveMeshConstraints: dict[str, AdaptiveMeshConstraint] = {}
1✔
212

213
    #: A repository of AdaptiveMeshControl objects.
214
    adaptiveMeshControls: dict[str, AdaptiveMeshControl] = {}
1✔
215

216
    #: A repository of TimePoint objects.
217
    timePoints: dict[str, TimePoint] = {}
1✔
218

219
    #: A repository of Filter objects.
220
    filters: dict[str, Filter] = {}
1✔
221

222
    #: A repository of IntegratedOutputSection objects.
223
    integratedOutputSections: dict[str, IntegratedOutputSection] = {}
1✔
224

225
    #: A repository of FieldOutputRequest objects.
226
    fieldOutputRequests: dict[str, FieldOutputRequest] = {}
1✔
227

228
    #: A repository of HistoryOutputRequest objects.
229
    historyOutputRequests: dict[str, HistoryOutputRequest] = {}
1✔
230

231
    #: A repository of OptimizationTask objects.
232
    optimizationTasks: dict[str, OptimizationTask] = {}
1✔
233

234
    @abaqus_method_doc
1✔
235
    def __init__(
1✔
236
        self,
237
        name: str,
238
        description: str = "",
239
        stefanBoltzmann: float | None = None,
240
        absoluteZero: float | None = None,
241
        waveFormulation: Literal[C.SCATTERED, C.NOT_SET, C.TOTAL] = NOT_SET,
242
        modelType: Literal[C.STANDARD_EXPLICIT, C.ELECTROMAGNETIC] = STANDARD_EXPLICIT,
243
        universalGas: float | None = None,
244
        copyConstraints: Boolean = ON,
245
        copyConnectors: Boolean = ON,
246
        copyInteractions: Boolean = ON,
247
    ):
248
        """This method creates a Model object.
249

250
        .. note::
251
            This function can be accessed by::
252

253
                mdb.Model
254

255
        Parameters
256
        ----------
257
        name
258
            A String specifying the repository key.
259
        description
260
            A String specifying the purpose and contents of the Model object. The default value is
261
            an empty string.
262
        stefanBoltzmann
263
            None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
264
        absoluteZero
265
            None or a Float specifying the absolute zero constant. The default value is None.
266
        waveFormulation
267
            A SymbolicConstant specifying the type of incident wave formulation to be used in
268
            acoustic problems. Possible values are NOT_SET, SCATTERED, and TOTAL. The default value
269
            is NOT_SET.
270
        modelType
271
            A SymbolicConstant specifying the analysis model type. Possible values are
272
            STANDARD_EXPLICIT and ELECTROMAGNETIC. The default is STANDARD_EXPLICIT.
273
        universalGas
274
            None or a Float specifying the universal gas constant. The default value is None.
275
        copyConstraints
276
            A boolean specifying whether to copy the constraints created in the model to the model
277
            that instances this model. The default value is ON.
278
        copyConnectors
279
            A boolean specifying whether to copy the connectors created in the model to the model
280
            that instances this model. The default value is ON.
281
        copyInteractions
282
            A boolean specifying whether to copy the interactions created in the model to the model
283
            that instances this model. The default value is ON.
284

285
        Returns
286
        -------
287
        Model
288
            A Model object.
289
        """
290
        from ..Assembly.Assembly import Assembly
1✔
291

292
        self.steps["Initial"] = InitialStep()
1✔
293
        self.rootAssembly = Assembly()
1✔
294

295
    @abaqus_method_doc
1✔
296
    def ModelFromInputFile(self, name: str, inputFileName: str):
1✔
297
        """This method creates a Model object by reading the keywords in an input file and creating the
298
        corresponding Abaqus/CAE objects.
299

300
        .. note::
301
            This function can be accessed by::
302

303
                mdb.Model
304

305
        Parameters
306
        ----------
307
        name
308
            A String specifying the repository key.
309
        inputFileName
310
            A String specifying the name of the input file (including the .inp extension) to be
311
            parsed into the new model. This String can also be the full path to the input file if it
312
            is located in another directory.
313

314
        Returns
315
        -------
316
        Model
317
            A Model object.
318
        """
319
        ...
×
320

321
    @abaqus_method_doc
1✔
322
    def ModelFromOdbFile(self, name: str, odbFileName: str):
1✔
323
        """This method creates a Model object by reading an output database and creating any corresponding
324
        Abaqus/CAE objects.
325

326
        .. note::
327
            This function can be accessed by::
328

329
                mdb.Model
330

331
        Parameters
332
        ----------
333
        name
334
            A String specifying the repository key.
335
        odbFileName
336
            A String specifying the name of the output database file (including the .odb extension)
337
            to be read into the new model. This String can also be the full path to the output
338
            database file if it is located in another directory.
339

340
        Returns
341
        -------
342
        Model
343
            A Model object.
344
        """
345
        ...
×
346

347
    @abaqus_method_doc
1✔
348
    def ModelFromNastranFile(
1✔
349
        self,
350
        modelName: str,
351
        inputFileName: str,
352
        sectionConsolidation: Literal[C.PRESERVE_SECTION, C.GROUP_BY_MATERIAL, C.NONE] = PRESERVE_SECTION,
353
        preIntegratedShell: Boolean = OFF,
354
        weightMassScaling: Boolean = ON,
355
        loadCases: Boolean = ON,
356
        coupleBeamOffsets: Boolean = ON,
357
        cbar: str = B31,
358
        cquad4: str = S4,
359
        chexa: str = C3D8I,
360
        ctetra: str = C3D10,
361
        keepTranslatedFiles: Boolean = ON,
362
    ):
363
        """This method creates a Model object by reading the keywords in a Nastran bulk data file or Nastran
364
        input file and creating any corresponding Abaqus/CAE objects. The default values is discussed in
365
        following and can be defined alternatively in the Abaqus environment file as the one used for the
366
        translator from Nastran to Abaqus. For more information, see Translating Nastran data to Abaqus files.
367

368
        .. note::
369
            This function can be accessed by::
370

371
                mdb.Model
372

373
        Parameters
374
        ----------
375
        modelName
376
            A String specifying the repository key.
377
        inputFileName
378
            A String specifying the name of the Nastran input file (including the .bdf, .dat, .nas,
379
            .nastran, .blk, .bulk extension) to be read into the new model. This String can also be
380
            the full path to the Nastran input file if it is located in another directory.
381
        sectionConsolidation
382
            A SymbolicConstant specifying the method used to create shell section. Possible values
383
            are PRESERVE_SECTION, GROUP_BY_MATERIAL, and NONE. If PRESERVE_SECTION is used, an
384
            Abaqus section is created corresponding to each shell property ID. If GROUP_BY_MATERIAL
385
            is used, a single Abaqus section is created for all homogeneous elements referencing the
386
            same material. In both cases, material orientations and offsets are created using
387
            discrete fields. If NONE is used, a separate shell section is created for each
388
            combination of orientation, material offset, and/or thickness. The default is
389
            PRESERVE_SECTION.
390
        preIntegratedShell
391
            A Boolean specifying whether the pre-integrated shell section is created in default for
392
            shell element. The default value is OFF.
393
        weightMassScaling
394
            A Boolean specifying whether the value on the Nastran data line PARAM, WTMASS is used as
395
            a multiplier for all density, mass, and rotary inertia values created in the Abaqus
396
            input file. The default value is ON.
397
        loadCases
398
            A Boolean specifying whether each SUBCASE for linear static analyses is translated to a
399
            LOAD CASE option, and all such LOAD CASE options are grouped in a single STEP option.
400
            The default value is ON.
401
        coupleBeamOffsets
402
            A Boolean specifying whether to translate the beam element connectivity to newly created
403
            nodes at the offset location and rigidly coupling the new and original nodes. If not,
404
            beam element offsets are translated to the CENTROID and SHEAR CENTER options, which are
405
            suboptions of the BEAM GENERAL SECTION option. The default value is ON. When the beam
406
            element references a PBARL or PBEAML property or if the beam offset has a significant
407
            component in the direction of the beam axis, the setting for this argument is always ON.
408
        cbar
409
            A String specifying the 2-node beam that is created from CBAR and CBEAM elements.
410
            Possible values are B31 and B33. The default is B31.
411
        cquad4
412
            A String specifying the 4-node shell that is created from CQUAD4 elements. Possible
413
            values are S4 and S4R. The default is S4. If a reduced-integration element is chosen,
414
            the enhanced hourglass formulation is applied automatically.
415
        chexa
416
            A String specifying the 8-node brick that is created from CHEXA elements. Possible
417
            values are C3D8I, C3D8 and C3D8R. The default is C3D8I. If a reduced-integration element
418
            is chosen, the enhanced hourglass formulation is applied automatically.
419
        ctetra
420
            A String specifying the 10-node tetrahedron that is created from CTETRA elements.
421
            Possible values are C3D10 and C3D10M. The default is C3D10.
422
        keepTranslatedFiles
423
            A Boolean specifying whether to keep the generated Abaqus input file after the model is
424
            created from the Nastran input file. The default value is ON.
425

426
        Returns
427
        -------
428
        Model
429
            A Model object.
430
        """
431
        ...
×
432

433
    @abaqus_method_doc
1✔
434
    def setValues(
1✔
435
        self,
436
        description: str = "",
437
        noPartsInputFile: Boolean = OFF,
438
        absoluteZero: float | None = None,
439
        stefanBoltzmann: float | None = None,
440
        waveFormulation: Literal[C.SCATTERED, C.NOT_SET, C.TOTAL] = NOT_SET,
441
        universalGas: float | None = None,
442
        restartJob: str = "",
443
        restartStep: str = "",
444
        restartIncrement: Literal[C.STEP_END] | None = None,
445
        endRestartStep: Boolean = OFF,
446
        globalJob: str = "",
447
        shellToSolid: Boolean = OFF,
448
        copyConstraints: Boolean = OFF,
449
        copyConnectors: Boolean = OFF,
450
        copyInteractions: Boolean = OFF,
451
    ):
452
        """This method modifies the Model object.
453

454
        Parameters
455
        ----------
456
        description
457
            A String specifying the purpose and contents of the Model object. The default value is
458
            an empty string.
459
        noPartsInputFile
460
            A Boolean specifying whether an input file should be written without parts and
461
            assemblies. The default value is OFF.
462
        absoluteZero
463
            None or a Float specifying the absolute zero constant. The default value is None.
464
        stefanBoltzmann
465
            None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
466
        waveFormulation
467
            A SymbolicConstant specifying the type of incident wave formulation to be used in
468
            acoustic problems. Possible values are NOT_SET, SCATTERED, and TOTAL. The default value
469
            is NOT_SET.
470
        universalGas
471
            None or a Float specifying the universal gas constant. The default value is None.
472
        restartJob
473
            A String specifying the name of the job that generated the restart data.
474
        restartStep
475
            A String specifying the name of the step where the restart analysis will start.
476
        restartIncrement
477
            An Int specifying the increment, interval, iteration or cycle where the restart analysis
478
            will start. To select the end of the step use the SymbolicConstant STEP_END.
479
        endRestartStep
480
            A Boolean specifying that the step specified by **restartStep** should be terminated at
481
            the increment specified by **restartIncrement**.
482
        globalJob
483
            A String specifying the name of the job that generated the results for the global model.
484
        shellToSolid
485
            A Boolean specifying that a shell global model drives a solid submodel.
486
        copyConstraints
487
            A Boolean specifying whether to copy the constraints created in the model to the model
488
            that instances this model.
489
        copyConnectors
490
            A Boolean specifying whether to copy the connectors created in the model to the model
491
            that instances this model
492
        copyInteractions
493
            A Boolean specifying whether to copy the interactions created in the model to the model
494
            that instances this model.
495
        """
496
        ...
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc