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

haiiliin / abqpy / 9778478820

03 Jul 2024 01:08PM UTC coverage: 73.934%. First build
9778478820

Pull #5645

github

web-flow
Merge ba87f5146 into 87547c9f4
Pull Request #5645: [bugfix] Move circular imports to `TYPE_CHECKING` blocks (backport #5586)

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

24668 of 33365 relevant lines covered (73.93%)

0.74 hits per line

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

95.61
/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 ..TableCollection.EventSeriesData import EventSeriesData
1✔
40
from ..TableCollection.EventSeriesType import EventSeriesType
1✔
41
from ..TableCollection.TableCollection import TableCollection
1✔
42
from ..UtilityAndView.abaqusConstants import (
1✔
43
    B31,
44
    C3D8I,
45
    C3D10,
46
    NOT_SET,
47
    OFF,
48
    ON,
49
    PRESERVE_SECTION,
50
    S4,
51
    STANDARD_EXPLICIT,
52
    Boolean,
53
    SymbolicConstant,
54
)
55
from ..UtilityAndView.abaqusConstants import abaqusConstants as C
1✔
56
from .KeywordBlock import KeywordBlock
1✔
57

58
if TYPE_CHECKING:
1✔
NEW
59
    from ..Assembly.Assembly import Assembly
×
60

61

62
@abaqus_class_doc
1✔
63
class ModelBase:
1✔
64
    """Abaqus creates a Model object named `Model-1` when a session is started.
65

66
    .. note::
67
        This object can be accessed by::
68

69
            mdb.models[name]
70

71
        The corresponding analysis keywords are:
72

73
        - PHYSICAL CONSTANTS
74
    """
75

76
    #: A String specifying the repository key.
77
    name: str = ""
1✔
78

79
    #: None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
80
    stefanBoltzmann: float | None = None
1✔
81

82
    #: None or a Float specifying the absolute zero constant. The default value is None.
83
    absoluteZero: float | None = None
1✔
84

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

90
    #: None or a Float specifying the universal gas constant. The default value is None.
91
    universalGas: float | None = None
1✔
92

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

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

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

105
    #: A Boolean specifying that a shell global model drives a solid submodel.
106
    shellToSolid: Boolean = OFF
1✔
107

108
    #: A Float specifying the time stamp that indicates when the model was last changed.
109
    lastChangedCount: float | None = None
1✔
110

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

115
    #: A String specifying the name of the job that generated the restart data.
116
    restartJob: str = ""
1✔
117

118
    #: A String specifying the name of the step where the restart analysis will start.
119
    restartStep: str = ""
1✔
120

121
    #: A String specifying the name of the job that generated the results for the global model.
122
    globalJob: str = ""
1✔
123

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

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

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

136
    #: A KeywordBlock object.
137
    keywordBlock: KeywordBlock = KeywordBlock()
1✔
138

139
    #: An Assembly object.
140
    rootAssembly: Assembly
1✔
141

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

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

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

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

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

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

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

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

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

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

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

175
    #: A repository of ContactStabilization objects.
176
    contactStabilizations: dict[str, ContactStabilization] = {}
1✔
177

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

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

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

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

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

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

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

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

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

207
    #: A repository of Step objects.
208
    steps: dict[str, Step] = {}
1✔
209

210
    #: A FeatureOptions object.
211
    featureOptions: FeatureOptions = FeatureOptions()
1✔
212

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

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

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

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

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

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

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

234
    #: A repository of OptimizationTask objects.
235
    optimizationTasks: dict[str, OptimizationTask] = {}
1✔
236

237
    #: A repository of TableCollection objects.
238
    #:
239
    #: .. versionadded:: 2020
240
    #:     The ``tableCollections`` attribute was added.
241
    tableCollections: dict[str, TableCollection] = {}
1✔
242

243
    #: A repository of EventSeriesType objects.
244
    #:
245
    #: .. versionadded:: 2020
246
    #:     The ``eventSeriesTypes`` attribute was added.
247
    eventSeriesTypes: dict[str, EventSeriesType] = {}
1✔
248

249
    #: A repository of EventSeriesData objects.
250
    #:
251
    #: .. versionadded:: 2020
252
    #:     The ``eventSeriesDatas`` attribute was added.
253
    eventSeriesDatas: dict[str, EventSeriesData] = {}
1✔
254

255
    @abaqus_method_doc
1✔
256
    def __init__(
1✔
257
        self,
258
        name: str,
259
        description: str = "",
260
        stefanBoltzmann: float | None = None,
261
        absoluteZero: float | None = None,
262
        waveFormulation: Literal[C.SCATTERED, C.NOT_SET, C.TOTAL] = NOT_SET,
263
        modelType: Literal[C.STANDARD_EXPLICIT, C.ELECTROMAGNETIC] = STANDARD_EXPLICIT,
264
        universalGas: float | None = None,
265
        copyConstraints: Boolean = ON,
266
        copyConnectors: Boolean = ON,
267
        copyInteractions: Boolean = ON,
268
    ):
269
        """This method creates a Model object.
270

271
        .. note::
272
            This function can be accessed by::
273

274
                mdb.Model
275

276
        Parameters
277
        ----------
278
        name
279
            A String specifying the repository key.
280
        description
281
            A String specifying the purpose and contents of the Model object. The default value is
282
            an empty string.
283
        stefanBoltzmann
284
            None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
285
        absoluteZero
286
            None or a Float specifying the absolute zero constant. The default value is None.
287
        waveFormulation
288
            A SymbolicConstant specifying the type of incident wave formulation to be used in
289
            acoustic problems. Possible values are NOT_SET, SCATTERED, and TOTAL. The default value
290
            is NOT_SET.
291
        modelType
292
            A SymbolicConstant specifying the analysis model type. Possible values are
293
            STANDARD_EXPLICIT and ELECTROMAGNETIC. The default is STANDARD_EXPLICIT.
294
        universalGas
295
            None or a Float specifying the universal gas constant. The default value is None.
296
        copyConstraints
297
            A boolean specifying whether to copy the constraints created in the model to the model
298
            that instances this model. The default value is ON.
299
        copyConnectors
300
            A boolean specifying whether to copy the connectors created in the model to the model
301
            that instances this model. The default value is ON.
302
        copyInteractions
303
            A boolean specifying whether to copy the interactions created in the model to the model
304
            that instances this model. The default value is ON.
305

306
        Returns
307
        -------
308
        Model
309
            A Model object.
310
        """
311
        from ..Assembly.Assembly import Assembly
1✔
312

313
        self.steps["Initial"] = InitialStep()
1✔
314
        self.rootAssembly = Assembly()
1✔
315

316
    @abaqus_method_doc
1✔
317
    def ModelFromInputFile(self, name: str, inputFileName: str):
1✔
318
        """This method creates a Model object by reading the keywords in an input file and creating the
319
        corresponding Abaqus/CAE objects.
320

321
        .. note::
322
            This function can be accessed by::
323

324
                mdb.Model
325

326
        Parameters
327
        ----------
328
        name
329
            A String specifying the repository key.
330
        inputFileName
331
            A String specifying the name of the input file (including the .inp extension) to be
332
            parsed into the new model. This String can also be the full path to the input file if it
333
            is located in another directory.
334

335
        Returns
336
        -------
337
        Model
338
            A Model object.
339
        """
340
        ...
×
341

342
    @abaqus_method_doc
1✔
343
    def ModelFromOdbFile(self, name: str, odbFileName: str):
1✔
344
        """This method creates a Model object by reading an output database and creating any corresponding
345
        Abaqus/CAE objects.
346

347
        .. note::
348
            This function can be accessed by::
349

350
                mdb.Model
351

352
        Parameters
353
        ----------
354
        name
355
            A String specifying the repository key.
356
        odbFileName
357
            A String specifying the name of the output database file (including the .odb extension)
358
            to be read into the new model. This String can also be the full path to the output
359
            database file if it is located in another directory.
360

361
        Returns
362
        -------
363
        Model
364
            A Model object.
365
        """
366
        ...
×
367

368
    @abaqus_method_doc
1✔
369
    def ModelFromNastranFile(
1✔
370
        self,
371
        modelName: str,
372
        inputFileName: str,
373
        sectionConsolidation: Literal[C.PRESERVE_SECTION, C.GROUP_BY_MATERIAL, C.NONE] = PRESERVE_SECTION,
374
        preIntegratedShell: Boolean = OFF,
375
        weightMassScaling: Boolean = ON,
376
        loadCases: Boolean = ON,
377
        coupleBeamOffsets: Boolean = ON,
378
        cbar: str = B31,
379
        cquad4: str = S4,
380
        chexa: str = C3D8I,
381
        ctetra: str = C3D10,
382
        keepTranslatedFiles: Boolean = ON,
383
    ):
384
        """This method creates a Model object by reading the keywords in a Nastran bulk data file or Nastran
385
        input file and creating any corresponding Abaqus/CAE objects. The default values is discussed in
386
        following and can be defined alternatively in the Abaqus environment file as the one used for the
387
        translator from Nastran to Abaqus. For more information, see Translating Nastran data to Abaqus files.
388

389
        .. note::
390
            This function can be accessed by::
391

392
                mdb.Model
393

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

447
        Returns
448
        -------
449
        Model
450
            A Model object.
451
        """
452
        ...
×
453

454
    @abaqus_method_doc
1✔
455
    def setValues(
1✔
456
        self,
457
        description: str = "",
458
        noPartsInputFile: Boolean = OFF,
459
        absoluteZero: float | None = None,
460
        stefanBoltzmann: float | None = None,
461
        waveFormulation: Literal[C.SCATTERED, C.NOT_SET, C.TOTAL] = NOT_SET,
462
        universalGas: float | None = None,
463
        restartJob: str = "",
464
        restartStep: str = "",
465
        restartIncrement: Literal[C.STEP_END] | None = None,
466
        endRestartStep: Boolean = OFF,
467
        globalJob: str = "",
468
        shellToSolid: Boolean = OFF,
469
        copyConstraints: Boolean = OFF,
470
        copyConnectors: Boolean = OFF,
471
        copyInteractions: Boolean = OFF,
472
    ):
473
        """This method modifies the Model object.
474

475
        Parameters
476
        ----------
477
        description
478
            A String specifying the purpose and contents of the Model object. The default value is
479
            an empty string.
480
        noPartsInputFile
481
            A Boolean specifying whether an input file should be written without parts and
482
            assemblies. The default value is OFF.
483
        absoluteZero
484
            None or a Float specifying the absolute zero constant. The default value is None.
485
        stefanBoltzmann
486
            None or a Float specifying the Stefan-Boltzmann constant. The default value is None.
487
        waveFormulation
488
            A SymbolicConstant specifying the type of incident wave formulation to be used in
489
            acoustic problems. Possible values are NOT_SET, SCATTERED, and TOTAL. The default value
490
            is NOT_SET.
491
        universalGas
492
            None or a Float specifying the universal gas constant. The default value is None.
493
        restartJob
494
            A String specifying the name of the job that generated the restart data.
495
        restartStep
496
            A String specifying the name of the step where the restart analysis will start.
497
        restartIncrement
498
            An Int specifying the increment, interval, iteration or cycle where the restart analysis
499
            will start. To select the end of the step use the SymbolicConstant STEP_END.
500
        endRestartStep
501
            A Boolean specifying that the step specified by **restartStep** should be terminated at
502
            the increment specified by **restartIncrement**.
503
        globalJob
504
            A String specifying the name of the job that generated the results for the global model.
505
        shellToSolid
506
            A Boolean specifying that a shell global model drives a solid submodel.
507
        copyConstraints
508
            A Boolean specifying whether to copy the constraints created in the model to the model
509
            that instances this model.
510
        copyConnectors
511
            A Boolean specifying whether to copy the connectors created in the model to the model
512
            that instances this model
513
        copyInteractions
514
            A Boolean specifying whether to copy the interactions created in the model to the model
515
            that instances this model.
516
        """
517
        ...
×
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