Oasys.THIS.Model class¶
Constants¶
- Model.ALL_FILES¶
Option to select all files (.thf, LSDA, ASCII, .ztf) when reading model in
- Model.ASCII¶
Option to select ASCII files when reading model in
- Model.LSDA¶
Option to select LSDA/binout file when reading model in
- Model.THF¶
Option to select .thf/d3thdt file when reading model in
- Model.XTF¶
Option to select .xtf/xtfile file when reading model in
- Model.ZTF¶
Option to select .ztf file when reading model in
Properties¶
Static methods¶
- classmethod Model.Exists(model_number)¶
Checks if a model exists
- Parameters:
model_number (integer) – The number of the model you want to check the existence of
- Returns:
True if the model exists, otherwise False
- Return type:
bool
Example
To check if a model n exists
exists = Oasys.THIS.Model.Exists(n)
- classmethod Model.GetFromID(model_number)¶
Returns the Model object for a model ID or None if model does not exist
- Parameters:
model_number (integer) – number of the model you want the Model object for
- Returns:
Model object (or None if model does not exist)
- Return type:
Model
Example
To get the model n
model = Oasys.THIS.Model.GetFromID(n)
- classmethod Model.HighestID()¶
Returns the ID of the highest model currently being used
- Returns:
ID of highest model currently being used
- Return type:
int
Example
To get the highest model ID
id = Oasys.THIS.Model.HighestID()
- classmethod Model.Read(filename, filetype=Oasys.gRPC.defaultArg)¶
Reads in a new model
- Parameters:
filename (string) – Filename you want to read
filetype (integer) – Optional. Filetypes you want to read. Can be bitwise OR of Model.THF, Model.XTF, Model.LSDA, Model.ASCII, Model.ZTF and Model.ALL_FILES. If omitted all available files will be read
- Returns:
Model object (or None if error)
- Return type:
Model
Example
To read in model /data/test/file.thf:
m = Oasys.THIS.Model.Read("/data/test/file.thf")To read in model /data/test/file.thf only with .ztf files:
m = Oasys.THIS.Model.Read("/data/test/file.thf", Oasys.THIS.Model.ZTF)To read in model /data/test/file.thf only with .thf, .ascii and .ztf files:
m = Oasys.THIS.Model.Read("/data/test/file.thf", Model.THF | Model.ASCII | Oasys.THIS.Model.ZTF)
- classmethod Model.Total()¶
Returns the total number of models
- Returns:
integer
- Return type:
int
Example
To find how many models there are in T/HIS:
num = Oasys.THIS.Model.Total()
Instance methods¶
- Model.ClearFlag(flag, entity_type, item, end=Oasys.gRPC.defaultArg)¶
Clears a defined flag on an internal (or external) item(s) of type of entity_type in the model
- Parameters:
flag (Flag) – The flag you want to clear
entity_type (integer) – The
Entity
type that the defined flag will be cleared onitem (integer) – If +ive: The internal item number starting from 1. If -ive: The external item label
end (integer) – Optional. To unflag range of items, specify an optional end of range. Unflags items from item to range
- Returns:
True if the flag is successfully cleared on the item, otherwise False
- Return type:
bool
Example
To clear the flag f on the 6th node in model m:
m.ClearFlag(f, Entity.NODE, 6)To clear the flag f on the Node 13456 in model m:
m.ClearFlag(f, Entity.NODE, -13456)To clear the flag f on the first 10 nodes in model m:
m.ClearFlag(f, Entity.NODE, 1, 10)To clear the flag f on nodes with labels 1000, 1001, 1002, …, 1009 in model m:
m.ClearFlag(f, Entity.NODE, -1000, -1009)
- Model.Delete()¶
Deletes a model
Do not use the Model object after calling this method
- Returns:
True if the model sucessfully deleted, otherwise False
- Return type:
bool
Example
To delete model m:
deleted = m.Delete()
- Model.FlagAll(flag, entity_type)¶
Sets a defined flag on all of items of type of entity_type in the model
- Parameters:
flag (Flag) – The flag you want to set
entity_type (integer) – The
Entity
type that the defined flag will be set on- Returns:
True if the flag is successfully set on all the items, otherwise False
- Return type:
bool
Example
To set the flag f on all the nodes in model m:
m.FlagAll(f, Entity.NODE)
- Model.Flagged(flag, entity_type, item)¶
Checks if a defined flag is set on an internal (or external) item of type of entity_type in the model
- Parameters:
flag (Flag) – The flag you want to check
entity_type (integer) – The
Entity
type to checkitem (integer) – If +ive: The internal item number starting from 1. If -ive: The external item label
- Returns:
True if the flag is set, False if the flag is not set
- Return type:
bool
Example
To check if flag f is set on the 6th node in model m:
m.Flagged(f, Entity.NODE, 6)To check if flag f is set on the Node 13456 in model m:
m.Flagged(f, Entity.NODE, -13456)
- Model.GetDataFlagged(flag, data_comp, int_pnt=Oasys.gRPC.defaultArg, extra=Oasys.gRPC.defaultArg)¶
Gets curve objects for a data component for relevant items that are flagged with a specified flag in the model.
Some data components are valid for different entity types (e.g. SXX). If the same flag is set on items of different entity types, data is returned for all relevant, flagged entity types.
To return the same data for multiple items of the same type, it will be much faster if you flag all items you want data for, and do a single call to GetDataFlagged().
The curves are ordered by type, then by the ascending internal index of the items. Usecurve properties
to identify which curve is which. If the data is not available in the model for a flagged item, or not available for the selected integration points or extra value, a curve is not returned. You can useQueryDataPresent()
to check if the data is available.
It is recommended that you check the number of curves returned. This can be compared with the number of flagged entities, seeGetNumberFlagged()
.
If the data is generally available in the model, but not for the specific flagged item, a “None curve” which contains no x-y data values is returned. For example, a specific shell may have fewer integration points than MAX_INT for all shells, a"null curve"
would be returned for the higher integration points.
- Parameters:
flag (Flag) – The flag to use. For model data, use 0 to define a None “padding” argument
data_comp (integer) – The Data
Component
to extractint_pnt (dict) –
Optional. The integration points to extract.
This argument can be either an integer or an object.
This argument is ignored when the entity type is not SOLID, SHELL, THICK_SHELL or BEAM.
An integer specifies the integration point to extract:
For SOLIDs: value between 0 for Average/Centre and 8. (Defaults to Average/Centre).
For SHELLs and THICK_SHELLs: value between 1 and # integration points, or codesConstant.TOP
,Constant.MIDDLE
,Constant.BOTTOM
. (Defaults to MIDDLE integration point).
For integrated BEAMs: value between 1 and # integration points. (Defaults to integration point 1).
Use 0 to define a None “padding” argument, then uses the default integration point
- ip:
(integer) Through thickness integration point as described above
- np (optional):
(integer) The nodes to extrapolate to. For SOLIDs, SHELLs and THICK_SHELLs: value between 1 and # nodes on the entity. (Defaults to none)
- op (optional):
(integer) On plan integration point. For SHELLs and THICK_SHELLs: value between 0 for Average/Centre and 4. (Defaults to Average/Centre)
extra (integer) – Optional. The extra component id for SOLIDs, SHELLs, THICK_SHELLs or BEAMs
- Returns:
List of Curve objects
- Return type:
list
Example
To get X direct stress for flagged SOLIDs, SHELLs and THICK_SHELLs with flag f in model m:
cur_list = m.GetDataFlagged(f, Component.SXX)To get X direct stress at top integration point for flagged SHELLs and THICK_SHELLs with flag f in model m:
cur_list = m.GetDataFlagged(f, Component.SXX, Constant.TOP)To get X direct stress at top integration point, and on-plan integration point 3 for flagged SHELLs and THICK_SHELLs with flag f in model m:
cur_list = m.GetDataFlagged(f, Component.SXX, {ip:Constant.TOP, op:3})To get extra beam data 3 for flagged BEAMs with flag f in model m:
cur_list = m.GetDataFlagged(f, Component.BEX, 0, 3)To get the total mass in model m:
cur_list = m.GetDataFlagged(0, Component.GMASS)
- Model.GetInternalID(entity_type, item)¶
Gets the internal ID of external item of type entity_type in the model
- Parameters:
entity_type (integer) – The
Entity
type of the itemitem (integer) – The external item number
- Returns:
Integer internal ID (starting from 1) with reference to the entity_type code. Returns integer internal ID of 0 if item cannot be found
- Return type:
int
Example
To get the internal ID of Airbag 300 in model m:
x = m.GetInternalID(Entity.AIRBAG, 300)
- Model.GetLabel(entity_type, item)¶
Gets the external label of internal item of type entity_type in the model
- Parameters:
entity_type (integer) – The
Entity
type of the itemitem (integer) – The internal item number starting from 1
- Returns:
Integer external ID (or 0 if there is an error, or the internal ID if there are no external IDs)
- Return type:
int
Example
To get the external ID of the 2nd airbag in model m:
x = m.GetLabel(Entity.AIRBAG, 2)
- Model.GetLabelFromName(entity_type, name)¶
Gets the external label from the database history name name of type entity_type in the model. This is quicker if you use parent entity type codes (e.g. Entity.WELD rather than Entity.WELD_CONSTRAINED)
- Parameters:
entity_type (integer) – The
Entity
type of the itemname (string) – The name of the item. If only the first part of the name is given, it must be unambiguous
- Returns:
Integer external ID of the first matching name (or 0 if there is an error)
- Return type:
int
Example
To get the external label the of Contact named “Rear Bolt” in database history:
name = m.GetLabelFromName(Entity.CONTACT, "Rear Bolt")
- Model.GetName(entity_type, item)¶
Gets the database history name of an internal (or external) item of type entity_type in the model
- Parameters:
entity_type (integer) – The
Entity
type of the itemitem (integer) – If +ive: The internal item number starting from 1. If -ive: The external item label
- Returns:
String containing the database history name (or None if not available)
- Return type:
str
Example
To get the database history name of the 2nd airbag in model m:
name = m.GetName(Entity.AIRBAG, 2)To get the database history name of Airbag 300 in model m:
name = m.GetName(Entity.AIRBAG, -300)
- Model.GetNumberFlagged(flag, entity_type=Oasys.gRPC.defaultArg)¶
Gets the number of entities flagged with a requested flag in the model
- Parameters:
flag (Flag) – The flag you want to check
entity_type (integer) – Optional. If specified, the
Entity
type to look at. If not specified, all types are looked at- Returns:
Integer number
- Return type:
int
Example
To get the number of airbag parts flagged with flag f in model m:
num = m.GetNumberFlagged(f, Entity.AIRBAG_PART_DATA)
- Model.GetNumberOf(entity_type)¶
Gets the number of entities of a requested type in the model
- Parameters:
entity_type (integer) – The
Entity
type that you want to know the number of- Returns:
Integer number
- Return type:
int
Example
To get the number of airbags in model m:
num = m.GetNumberOf(Entity.AIRBAG)
- Model.QueryDataPresent(data_comp, entity_type=Oasys.gRPC.defaultArg, int_pnt=Oasys.gRPC.defaultArg, extra=Oasys.gRPC.defaultArg)¶
Checks if a data component data_comp for a given entity is present in a model’s database. For SOLIDs, SHELLs, THICK_SHELLs and BEAMs the integration point and extra component ID can also be checked. This will show if curves for any flagged items of this type will be returned for
GetDataFlagged()
. Note, it does not check if the data component is valid, for example a specific shell may have fewer integration points than MAX_INT for all shells, so curves returned forGetDataFlagged()
may still be “None” with no x-y data
- Parameters:
data_comp (integer) – The Data
Component
to checkentity_type (integer) – Optional. The
Entity
type to check. This argument can only be omitted when checking for global model dataint_pnt (dict) –
Optional. The integration points to check.
This argument can be either an integer or an object.
This argument is ignored if the entity type is not SOLID, SHELL, THICK_SHELL or BEAM.
An integer specifies the integration point to check:
For SOLIDs: value between 0 for Average/Centre and 8. (Defaults to Average/Centre).
For SHELLs and THICK_SHELLs: value between 1 and # integration points, or codesConstant.TOP
,Constant.MIDDLE
,Constant.BOTTOM
. (Defaults to MIDDLE integration point).
For integrated BEAMs: value between 1 and # integration points. (Defaults to integration point 1).
Use 0 to define a None “padding” argument, then checks the default integration point
- ip:
(integer) Through thickness integration point as described above
- np (optional):
(integer) The nodes to extrapolate to. For SOLIDs, SHELLs and THICK_SHELLs: value between 1 and # nodes on the entity. (Defaults to none)
- op (optional):
(integer) On plan integration point. For SHELLs and THICK_SHELLs: value between 0 for Average/Centre and 4. (Defaults to Average/Centre)
extra (integer) – Optional. The extra component id for SOLIDs, SHELLs, THICK_SHELLs or BEAMs
- Returns:
True if data is present, otherwise False
- Return type:
bool
Example
To check for X direct stress data for SOLIDs in model m:
m.QueryDataPresent(Component.SXX, Entity.SOLID))To check for X direct stress data at integration point 5 for SHELLs in model m:
m.QueryDataPresent(Component.SXX, Entity.SHELL, 5))To check for X direct stress data at both the top integration point, and also extrapolated to node 3 for SHELLs in model m:
m.QueryDataPresent(Component.SXX, Entity.SHELL, {ip:Constant.TOP, np:3})To check for extra 3 beam data for BEAMs in model m:
m.QueryDataPresent(Component.BEX, Entity.BEAM, 0, 3)To check for total mass data in model m:
m.QueryDataPresent(Component.GMASS))
- Model.SetFlag(flag, entity_type, item, end=Oasys.gRPC.defaultArg)¶
Sets a defined flag on an internal (or external) item(s) of type of entity_type in the model
- Parameters:
flag (Flag) – The flag you want to set
entity_type (integer) – The
Entity
type that the defined flag will be set onitem (integer) – If +ive: The internal item number starting from 1. If -ive: The external item label
end (integer) – Optional. To flag range of items, specify an optional end of range. Flags items from item to range
- Returns:
True if the flag is successfully set on the item, otherwise False
- Return type:
bool
Example
To set the flag f on the 6th node in model m:
m.SetFlag(f, Entity.NODE, 6)To set the flag f on the Node 13456 in model m:
m.SetFlag(f, Entity.NODE, -13456)To set the flag f on the first 10 nodes in model m:
m.SetFlag(f, Entity.NODE, 1, 10)To set the flag f on nodes with labels 1000, 1001, 1002, …, 1009 in model m:
m.SetFlag(f, Entity.NODE, -1000, -1009)
- Model.UnflagAll(flag, entity_type)¶
Unsets a defined flag flag on all of items of type of entity_type in the model
- Parameters:
flag (Flag) – The flag you want to unset
entity_type (integer) – The
Entity
type that the defined flag will be unset on- Returns:
True if the flag is successfully unset on all the items, otherwise False
- Return type:
bool
Example
To unset the flag f on all the nodes in model m:
m.UnflagAll(f, Entity.NODE)