import sys # Path containing PyF3D.dll / PyF3D.pyd sys.path.append(r"C:\\Program Files (x86)\\franc3d") import PyF3D # --------------------------------------------------------------------------- # Input model and FRANC3D files # --------------------------------------------------------------------------- MODEL_TYPE = "ABAQUS" ORIGINAL_MODEL = "Abaqus-Cube.inp" LOCAL_MODEL = "Abaqus-Cube_LOCAL.inp" GLOBAL_MODEL = "Abaqus-Cube_GLOBAL.inp" RETAINED_ELEMS = "Abaqus-Cube_RETAINED_ELEMS.txt" # --------------------------------------------------------------------------- # Family of initial elliptical cracks # # flaw_params = [crack_size_1, crack_size_2] # # The values below are examples and should be replaced with the desired # family of crack sizes for the cube model. # --------------------------------------------------------------------------- CRACK_FAMILY = [ { "name": "a015_c015", "flaw_params": [0.15, 0.15], }, { "name": "a020_c020", "flaw_params": [0.20, 0.20], }, { "name": "a025_c025", "flaw_params": [0.25, 0.25], }, { "name": "a030_c030", "flaw_params": [0.30, 0.30], }, ] # --------------------------------------------------------------------------- # Crack location and orientation # # These are taken from the documented Version 9.2 elliptical-flaw example. # Modify these values for the actual location/orientation of the cube crack. # --------------------------------------------------------------------------- ROTATION_AXES = [1] ROTATION_MAG = [90] TRANSLATION = [5, 5, 10] # Crack-front template radius TEMP_RADIUS = 0.03 # --------------------------------------------------------------------------- # Create FRANC3D application # --------------------------------------------------------------------------- f3d = PyF3D.F3DApp("wait_for_license") f3d.StartRecording ('my_session.log') # --------------------------------------------------------------------------- # Create the local/global submodel from the uncracked Abaqus model. # # This is the same Submodeler pattern used by cube_crack_insert_grow.txt. # --------------------------------------------------------------------------- f3d.Submodeler( model_type="ABAQUS", orig_file_name=ORIGINAL_MODEL, submodel_file_name=LOCAL_MODEL, global_file_name=GLOBAL_MODEL, elem_file_name=RETAINED_ELEMS) # --------------------------------------------------------------------------- # Process each elliptical initial crack. # --------------------------------------------------------------------------- for crack_number, crack in enumerate(CRACK_FAMILY, start=1): crack_name = crack["name"] print() print("=" * 70) print(f"Processing crack {crack_number}: {crack_name}") print("=" * 70) fdb_name = f"Abaqus-Cube_{crack_name}" job_name = f"{fdb_name}_full" fdb_file = f"{fdb_name}.fdb" sif_file = f"{fdb_name}.sif" # --------------------------------------------------------------- # Open a fresh copy of the uncracked local model for this crack. # # This is important: each member of CRACK_FAMILY is an independent # initial crack rather than a crack grown from the preceding one. # --------------------------------------------------------------- f3d.OpenMeshModel( model_type="ABAQUS", file_name=LOCAL_MODEL, global_name=GLOBAL_MODEL) # --------------------------------------------------------------- # Insert the parameterized elliptical crack. # # These are the exact Version 9.2 InsertParamFlaw parameter names. # --------------------------------------------------------------- f3d.InsertParamFlaw( flaw_type="CRACK", crack_type="ELLIPSE", flaw_params=crack["flaw_params"], rotation_axes=ROTATION_AXES, rotation_mag=ROTATION_MAG, translation=TRANSLATION, temp_radius=TEMP_RADIUS) # --------------------------------------------------------------- # Run the Abaqus FE analysis. # # FRANC3D parses the command string to identify the Abaqus # executable or batch file and its command-line arguments. # --------------------------------------------------------------- f3d.RunAnalysis( model_type="ABAQUS", file_name=fdb_file, merge_tol=0.0001, connection_type="MERGE", command=( f'"abaqus.bat" ' f'job={job_name} ' f'ask_delete=NO -interactive -analysis ' ), global_model=GLOBAL_MODEL, merge_surf_labels=["AUTO_CUT_SURF"], global_surf_labels=["GLOBAL_CONNECT_SURF"] ) # --------------------------------------------------------------- # Calculate the crack-front stress intensity factors. # --------------------------------------------------------------- f3d.ComputeSif() # --------------------------------------------------------------- # Write the SIFs for this crack to a file. # # TAB = tab-delimited output # KI = Mode I SIF # KII = Mode II SIF # KIII = Mode III SIF # CRD = crack-front coordinates # --------------------------------------------------------------- f3d.WriteSif( file_name=sif_file, crack_step=1, load_step=1, flags=["TAB", "KI", "KII", "KIII", "CRD"]) # --------------------------------------------------------------- # Close this crack model before starting the next independent # crack insertion. # --------------------------------------------------------------- f3d.CloseModel() print(f"Completed: {crack_name}") print(f"SIF file: {sif_file}") print() print("All elliptical crack analyses completed.")