def write_data_to_odb(array_file_name, pickle_file_name): field = np.load(array_file_name) with open(pickle_file_name, 'rb') as pickle_file: data = pickle.load(pickle_file) field_id = str(data['field_id']) instance_name = str(data['instance_name']) set_name = str(data['set_name']) odb_file = str(data['odb_file']) step_name = str(data['step_name']) step_description = str(data['step_description']) field_description = str(data['field_description']) frame_number = data['frame_number'] frame_value = data['frame_value'] position = INTEGRATION_POINT if data['position'] == 'NODAL': position = NODAL invariants = None if field_id == 'S': invariants = [PRESS, MISES] write_field_to_odb(field, field_id, odb_file, step_name=step_name, instance_name=instance_name, set_name=set_name, step_description=step_description, frame_number=frame_number, frame_value=frame_value, field_description=field_description, position=position, invariants=invariants)
def create_dante_step(results_odb_name, carbon_odb_name, stress_odb_name, results_step_name): f = read_field_from_odb(field_id='CONC', odb_file_name=carbon_odb_name, element_set_name='GEARELEMS', step_name='Carburization-3', frame_number=-1) hardness = -1.95704040e+09 * f**3 + 1.79113930e+07 * f**2 + 5.50685403e+04 * f + 2.27359677e+02 write_field_to_odb(field_data=hardness, field_id='HV', odb_file_name=results_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0) hardness = flip_node_order(hardness, axis='z') write_field_to_odb(field_data=hardness, field_id='HV', odb_file_name=results_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0) stress = read_field_from_odb(field_id='S', odb_file_name=stress_odb_name, element_set_name='GEARELEMS', step_name='Equilibrium', frame_number=-1, coordinate_system=cylindrical_system_z) write_field_to_odb( field_data=stress, field_id='S', odb_file_name=results_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) stress = flip_node_order(stress, axis='z') stress[:, 3] *= -1 write_field_to_odb( field_data=stress, field_id='S', odb_file_name=results_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL])
def create_dante_step(from_odb_name, to_odb_name, results_step_name): # Inspect the odb to get available data from_odb = openOdb(from_odb_name, readOnly=False) last_step_name, last_step = from_odb.steps.items()[-1] scalar_variables = last_step.frames[-1].fieldOutputs.keys() from_odb.close() if 'NT11' in scalar_variables: scalar_variables.remove('NT11') if 'U' in scalar_variables: scalar_variables.remove('U') if 'S' in scalar_variables: scalar_variables.remove('S') data_dict = {} for scalar_variable in scalar_variables: print "reading variable", scalar_variable data_dict[scalar_variable] = read_field_from_odb( scalar_variable, from_odb_name, last_step_name, -1) data_dict['S'] = read_field_from_odb('S', from_odb_name, last_step_name, -1) for scalar_variable in scalar_variables: field = data_dict[scalar_variable] write_field_to_odb(field_data=field, field_id=scalar_variable, odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part', frame_number=0) stress = data_dict['S'] write_field_to_odb( field_data=stress, field_id='S', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) hv = HRC2HV(data_dict['SDV_HARDNESS']) write_field_to_odb(field_data=hv, field_id='HV', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part', frame_number=0)
def create_dante_step(from_odb_name, to_odb_name, results_step_name, from_step=None): # Inspect the odb to get available data # Inspect the odb to get available data from_odb = openOdb(from_odb_name, readOnly=False) if from_step is None: step_name, _ = from_odb.steps.items()[-1] else: step_name = from_step scalar_variables = from_odb.steps[step_name].frames[-1].fieldOutputs.keys() from_odb.close() if 'NT11' in scalar_variables: scalar_variables.remove('NT11') if 'U' in scalar_variables: scalar_variables.remove('U') if 'S' in scalar_variables: scalar_variables.remove('S') if 'E' in scalar_variables: scalar_variables.remove('E') data_dict = {} for scalar_variable in scalar_variables: print "reading variable", scalar_variable data_dict[scalar_variable] = read_field_from_odb( scalar_variable, from_odb_name, step_name, -1) data_dict['S'] = read_field_from_odb('S', from_odb_name, step_name, -1) data_dict['HV'] = HRC2HV(data_dict['SDV_HARDNESS']) scalar_variables.append('HV') for scalar_variable in scalar_variables: print "Write field", scalar_variable field = data_dict[scalar_variable] write_field_to_odb(field_data=field, field_id=scalar_variable, odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part_pos', frame_number=0) field = flip_node_order(field, axis='z') write_field_to_odb(field_data=field, field_id=scalar_variable, odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part_neg', frame_number=0) print "Write stress" stress = data_dict['S'] write_field_to_odb( field_data=stress, field_id='S', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part_pos', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) stress = flip_node_order(stress, axis='z') stress[:, 3] *= -1 stress[:, 5] *= -1 write_field_to_odb( field_data=stress, field_id='S', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='specimen_part_neg', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL])
from abaqusConstants import MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL import sys from odb_io_functions import read_field_from_odb from odb_io_functions import write_field_to_odb from odb_io_functions import cylindrical_system_z # There are a lot of arguments to abaqus just use the seven last ones from_odb_name = sys.argv[-5] to_odb_name = sys.argv[-4] from_step = sys.argv[-3] from_frame = int(sys.argv[-2]) to_step = sys.argv[-1] stress_data = read_field_from_odb('S', from_odb_name, from_step, from_frame, element_set_name='GEARELEMS', instance_name='EVAL_TOOTH_1', coordinate_system=cylindrical_system_z) write_field_to_odb( stress_data, 'S', to_odb_name, to_step, instance_name='tooth_left', invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL])
point2=(0.0, 84.5, 0.0), system_type=CYLINDRICAL) stress_data = read_field_from_odb('S', from_odb_name, from_step, from_frame, element_set_name='GEARELEMS', instance_name='EVAL_TOOTH_0', coordinate_system=planet_system, rotating_system=True) write_field_to_odb( stress_data, 'S', to_odb_name, to_step, frame_number=to_frame, frame_value=to_frame_value, instance_name='tooth_right', invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) stress_data = read_field_from_odb('S', from_odb_name, from_step, from_frame, element_set_name='GEARELEMS', instance_name='EVAL_TOOTH_1', coordinate_system=planet_system, rotating_system=True) write_field_to_odb( stress_data,
def create_dante_step(from_odb_name, to_odb_name, results_step_name, from_step=None): # Inspect the odb to get available data from_odb = openOdb(from_odb_name, readOnly=False) if from_step is None: step_name, _ = from_odb.steps.items()[-1] else: step_name = from_step scalar_variables = from_odb.steps[step_name].frames[-1].fieldOutputs.keys() from_odb.close() if 'NT11' in scalar_variables: scalar_variables.remove('NT11') if 'U' in scalar_variables: scalar_variables.remove('U') if 'E' in scalar_variables: scalar_variables.remove('E') if 'S' in scalar_variables: scalar_variables.remove('S') data_dict = {} for scalar_variable in scalar_variables: print("reading variable", scalar_variable) data_dict[scalar_variable] = read_field_from_odb( scalar_variable, from_odb_name, step_name, -1) data_dict['S'] = read_field_from_odb('S', from_odb_name, step_name, -1) for scalar_field in scalar_variables: field = data_dict[scalar_field] write_field_to_odb(field_data=field, field_id=scalar_field, odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0) field = flip_node_order(field, axis='z') write_field_to_odb(field_data=field, field_id=scalar_field, odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0) stress = data_dict['S'] write_field_to_odb( field_data=stress, field_id='S', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) stress = flip_node_order(stress, axis='z') stress[:, 3:5] *= -1 write_field_to_odb( field_data=data_dict['S'], field_id='S', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0, invariants=[MISES, MAX_PRINCIPAL, MID_PRINCIPAL, MIN_PRINCIPAL]) hv = HRC2HV(data_dict['SDV_HARDNESS']) write_field_to_odb(field_data=hv, field_id='HV', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0) hv = flip_node_order(hv, axis='z') write_field_to_odb(field_data=hv, field_id='HV', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0) bainite = data_dict['SDV_UBAINITE'] + data_dict['SDV_LBAINITE'] write_field_to_odb(field_data=bainite, field_id='BAINITE', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_right', frame_number=0) bainite = flip_node_order(bainite, 'z') write_field_to_odb(field_data=bainite, field_id='BAINITE', odb_file_name=to_odb_name, step_name=results_step_name, instance_name='tooth_left', frame_number=0)
create_odb(odb_file_name=expansion_odb_filename, instance_data=instances) fields_to_process = [ 'SDV_Q_MARTENSITE', 'SDV_CARBON', 'SDV_AUSTENITE', 'SDV_LBAINITE', 'SDV_UBAINITE' ] for cd in [0.5, 0.8, 1.1, 1.4]: dante_step_name = 'dante_results_' + str(cd).replace('.', '_') node_data = create_node_field_from_element_field( fields_to_process, dante_odb_filename, None, dante_step_name, 0, 'tooth_right') for field_id, data in node_data.iteritems(): write_field_to_odb(data, field_id, expansion_odb_filename, dante_step_name, position=NODAL, instance_name='PART-1-1', frame_number=0) odb = odbAccess.openOdb(expansion_odb_filename) if 'expansion' + str(cd).replace('.', '_') not in odb.steps.keys(): expansion_step = odb.Step(name='expansion' + str(cd).replace('.', '_'), description='', domain=TIME, timePeriod=1) expansion_step.Frame(incrementNumber=0, frameValue=0, description='') expansion_step.Frame(incrementNumber=1,
directory[5:] for directory in findley_parameter_directories ] findley_parameters.sort(key=lambda x: float(x.replace('_', '.'))) for findley_parameter in findley_parameters: pickle_filenames = glob.glob(findley_pickle_directory + 'a800=' + findley_parameter + '/findley_' + specimen + '_R=' + str(int(R)) + '_' + 's=*.pkl') stress_amps = [ filename[-10:-7] for filename in pickle_filenames ] stress_amps = sorted(stress_amps) pickle_filenames = sorted(pickle_filenames, key=lambda x: x[-10:-7]) for pickle_file, load in zip(pickle_filenames, stress_amps): print 'loading pickle file', pickle_file with open(pickle_file, 'r') as pickle_handle: findley_stress = pickle.load(pickle_handle) step_name = 'a800=' + findley_parameter + '_s=' + str( load) + 'MPa' write_field_to_odb(findley_stress, 'SF', odb_file_name, step_name, frame_number=0, set_name=element_set_name) print 'Done with step', step_name