Skip to content

Commit

Permalink
Merge branch 'abaqus_event_series_as_return' into 'main'
Browse files Browse the repository at this point in the history
func generate_abaqus_event_series now returns a tuple for direct use with ABAQUS. Closes #14

Closes #14

See merge request kit/fast/lb/collaboration/additive-manufacturing/pygcodedecode!18
  • Loading branch information
lukashof committed Jan 18, 2024
2 parents 896b378 + f7d61c3 commit 0313d51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example/validation_submodel/call_aniso.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
print("---Simulation took %s seconds ---" % (time.time() - start_time))

# ---RESULTS--- #
afg.generate_abaqus_events(simulation=simulation, filename="example/validation_submodel/time_series.inp")
afg.generate_abaqus_event_series(simulation=simulation, filename="example/validation_submodel/time_series.inp")

print_layertimes(simulation=simulation, filename="example/validation_submodel/layertime_aniso.csv")

Expand Down
34 changes: 22 additions & 12 deletions pyGCodeDecode/abaqus_file_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@
0.0, 1.0, 0.0, 2.0, 1
0.44, 1.0, 22.0, 2.0, 0
timepoints generated are always at segment beginnings / endings, so interpolation linearly is the exact solution
time points generated are always at segment beginnings / endings, so interpolation linearly is the exact solution
"""
tolerance = float("1e-12")


def generate_abaqus_events(simulation: "gi.simulation", filename="pyGcodeDecode_abaqus_events.inp"):
def generate_abaqus_event_series(
simulation: gi.simulation, filename: str = "pyGcodeDecode_abaqus_events.inp", tolerance: float = 1e-12
) -> tuple:
"""Generate abaqus event series.
Parameters:
simulation: (simulation) simulation instance
filename: (string, default = "pyGcodeDecode_abaqus_events.inp") output file name
Args:
simulation (gi.simulation): simulation instance
filename (string, default = "pyGcodeDecode_abaqus_events.inp"): output file name
tolerance (float, default = 1e-12): tolerance to determine whether extrusion is happening
Returns:
tuple: the event series as a tuple for use in ABAQUS-Python
"""
# get all positions and timings
unpacked = gi.unpack_blocklist(simulation.blocklist)
pos = [unpacked[0].pos_begin.get_vec(withExtrusion=True)]
time = [0]
Expand All @@ -40,8 +44,14 @@ def generate_abaqus_events(simulation: "gi.simulation", filename="pyGcodeDecode_
pos[id][3] = 0
pos[-1][3] = 0

# writeout to file
f = open(filename, "w")
for time, pos in zip(time, pos):
f.write(str(time) + "," + str(pos[0]) + "," + str(pos[1]) + "," + str(pos[2]) + "," + str(pos[3]) + "\n")
f.close()
event_series_list = []

# write to file
with open(filename, "w") as outfile:
for time, pos in zip(time, pos):
outfile.write(
str(time) + "," + str(pos[0]) + "," + str(pos[1]) + "," + str(pos[2]) + "," + str(pos[3]) + "\n"
)
event_series_list.append((time, pos[0], pos[1], pos[2], pos[3]))

return tuple(event_series_list)

0 comments on commit 0313d51

Please sign in to comment.