How to effciently use a field-MOP in oSL to evaluate stresses from a load history?
Javier Vique
Member, Employee Posts: 86
✭✭✭✭
in Structures
Once field-MOP is created in oSL 3D Postprocessing, we want to make use of it to generate csv files with the full stress tensor for a load history. How to make it efficiently?
Tagged:
0
Answers
-
The user needs to save *.sdb file from field-MOP without any field and scalar data (just field-MOP). Then this sdb file is included as input together with a csv file with the load history. Below the used code:
try: from sos_package import sos, tmath except: print("ERROR: failed to load SoS module \ An optiSlang Enterprise license is required. \ An Ansys licensing client installation is required. \ Check your environment variables, see \ https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v212/en/opti_inst_lic/opti_inst_lic_config_requirements.html") ''' This SoS script is used to generate random field and Field-MOP designs from scalar input paramaters. The amplitudes are given for each design separately (CSV inputs_file). Auxiliary data are given by a SoS database file (database_file). The created field data are exported to csv formats. @generated by optiSLang 3D Postprocessing Dev 24R2 (24.2.0-53-g6f7ac4aca) ''' sos.requireMinVersion(24,2,0,53); sos.sceneManager().setGraphicsEnabled(False) # improve speed if no graphics is required. Comment this line if you need graphics. sos.MeshMorpherSettings.use_linearized_quadratic_elements = True # enforce linear curvature of quadratic finite elements in mesh morphing. # Import database with simulation data print("Load database with simulation data...") settings = sos.LoadDataBaseSettings(database_file) settings.create_reference_mesh = False; # use this option carefully! sos.loadDataBase(sos.database(), settings); print("Load database with simulation data... finished"); # Import values of amplitudes # Note: The CSV importer expects a single column and will associate this column with design number 1 print("Import values of amplitudes/inputs..."); importer = sos.ImportCSV(inputs_file); #importer.row_orientated = False; importer._import(sos.database()); print("Import values of amplitudes/inputs... finished"); def predictor(save_dir: str = OSL_DESIGN_DIR, t: int = 1, export_format: str = "nodes") -> None: export_reference_design = sos.ExportReferenceDesign(save_dir); if export_format == "nodes": export_reference_design.addNewFile_NodeDataCSV(sos.database(), "txtformat_nodal_SX.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SX_t{t}.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SXY_t{t}.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SXZ_t{t}.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SY_t{t}.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SYZ_t{t}.csv"); export_reference_design.addNewFile_NodeDataCSV(sos.database(), f"SZ_t{t}.csv"); item_idx = export_reference_design.getItemIndex(f"SX_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SX"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SXY_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SXY"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SXZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SXZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SY_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SY"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SYZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); elif export_format == "coords": export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SX_t{t}.csv"); export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SXY_t{t}.csv"); export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SXZ_t{t}.csv"); export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SY_t{t}.csv"); export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SYZ_t{t}.csv"); export_reference_design.addNewFile_ExternalDataCSV_NodeData(sos.database(), f"SZ_t{t}.csv"); item_idx = export_reference_design.getItemIndex(f"SX_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SX"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SXY_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SXY"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SXZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SXZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SY_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SY"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SYZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); item_idx = export_reference_design.getItemIndex(f"SZ_t{t}.csv", sos.ExportItemInfo.NODE_DATA); export_reference_design.setExportQuantity(item_idx, "SZ"); export_reference_design.setExportSource(item_idx, sos.ExportItemInfo.FMOP); else: raise Exception("Export Format not Supported (Supported Formats: 'nodes' or 'coords'), or check spelling.") export_reference_design.mesh_smoothening = False; export_reference_design.throw_error_on_unstable_mesh = False; export_reference_design.fmop_use_sampling_bounds = True; # perform the file operations: export_reference_design.modifyDesign(sos.database(), i); # Get Load History Length with open(inputs_file, 'r') as lh: lh_len = len(lh.readlines())-1 print('Total lines:', lh_len) # # Export field data print("Export generated field data..."); for i in range(1,lh_len+1): predictor(OSL_DESIGN_DIR, i, export_format="nodes") print("Export generated field data... finished"); print("Terminate script with success.");
0