Skip to content

Commit

Permalink
update v0.4.0 --> v0.4.1
Browse files Browse the repository at this point in the history
bugs
  • Loading branch information
avgcampos committed Aug 22, 2024
1 parent 0b1df23 commit 73ca145
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 49 deletions.
Binary file added docs/tutoriais/sim_dynamic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 4 additions & 12 deletions myfempy/core/material/heatplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getElasticTensor(Kxx, Kyy):
D[1, 1] = Kyy
return D

def getElementStrain(Model, U, ptg, element_number):
def getElementGradTemp(Model, U, ptg, element_number):
elem_set = Model.element.getElementSet()
nodedof = len(elem_set["dofs"]["d"])

Expand All @@ -49,11 +49,11 @@ def getElementStrain(Model, U, ptg, element_number):

return epsilon, strain

def getTitleStrain():
def getTitleGradTemp():
title = ["GRADTEMP", "GRADTEMP_XX", "GRADTEMP_YY"]
return title

def getElementStress(Model, epsilon, element_number):
def getElementHeatFlux(Model, epsilon, element_number):
Kxx = Model.tabmat[int(Model.inci[element_number, 2]) - 1]["KXX"]
Kyy = Model.tabmat[int(Model.inci[element_number, 2]) - 1]["KYY"]

Expand All @@ -70,14 +70,6 @@ def getElementStress(Model, epsilon, element_number):

return sigma, stress

def getTitleStress():
def getTitleHeatFlux():
title = ["HEATFLUX_MAG", "HEATFLUX_XX", "HEATFLUX_YY"]
return title

def getStrainEnergyDensity(sigma, epsilon, elemvol):
strain_energy = 0
return strain_energy

def getTitleCompliance():
title = ["STRAIN_ENERGY_DENSITY"]
return title
Empty file.
7 changes: 7 additions & 0 deletions myfempy/core/material/planestrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ def getElementStress(Model, epsilon, element_number):
def getTitleStress():
title = ["STRESS_VM", "STRESS_XX", "STRESS_YY", "STRESS_XY"]
return title

def getFailureCriteria(sigma):
return 0.0

def getTitleFoS():
title = ["FoS_YIELD_VON_MISES"]
return title
9 changes: 9 additions & 0 deletions myfempy/core/material/planestress.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,12 @@ def getStrainEnergyDensity(sigma, epsilon, elemvol):
def getTitleCompliance():
title = ["STRAIN_ENERGY_DENSITY"]
return title

def getFailureCriteria(sigma):
return 0.0

def getTitleFoS():
title = ["FoS_YIELD_VON_MISES"]
return title


22 changes: 21 additions & 1 deletion myfempy/io/iovtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,27 @@ def convert_to_vtk(plotdata):
0, int(len(plotdata["modes_POINT_DATA"][md]["val"][:, 1:]))
):
list2write = (
plotdata["modes_POINT_DATA"][md]["val"][:, 1:][ii, :]
plotdata["modes_POINT_DATA"][md]["val"][ii, :]
.astype(str)
.tolist()
)
file_object.write(" ".join(list2write) + "\n")

if "frf_POINT_DATA" in plotdata.keys():
for md in range(0, int(len(plotdata["frf_POINT_DATA"]))):
file_object.write("\n")
file_object.write("FIELD FieldData 1\n")
file_object.write(
plotdata["frf_POINT_DATA"][md]["title"]
+ " 3 "
+ str(int(len(plotdata["frf_POINT_DATA"][md]["val"][:, 1:])))
+ " float\n"
)
for ii in range(
0, int(len(plotdata["frf_POINT_DATA"][md]["val"][:, 1:]))
):
list2write = (
plotdata["frf_POINT_DATA"][md]["val"][ii, :]
.astype(str)
.tolist()
)
Expand Down
111 changes: 75 additions & 36 deletions myfempy/setup/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def getCompute(self, postprocset):
# print_console("post")

postprocdata = dict()
postprocdata['SOLUTION'] = []
postprocdata["solverstatus"] = postprocset["SOLVERDATA"]["solverstatus"]
SOLUTION = postprocset["SOLVERDATA"]["solution"]["U"]

Expand All @@ -58,9 +59,8 @@ def getCompute(self, postprocset):
}
)

postprocdata[sol_title] = result_solu[st, :, :]

# for setpost in range(result_solu.shape[2]):
postprocdata['SOLUTION'].append({sol_title:result_solu[st, :, :],
'STEP':st+1})

if (
"stress" in postprocset["COMPUTER"]["structural"].keys()
Expand All @@ -74,7 +74,7 @@ def getCompute(self, postprocset):
)
)

for ns in range(SOLUTION.shape[1]):
for st in range(SOLUTION.shape[1]):
result_stress[ns, :, :], title = setPostProcess.__stress(
self, SOLUTION[:, ns]
)
Expand All @@ -89,11 +89,6 @@ def getCompute(self, postprocset):
)
else:
pass

# if "dynamic" in postprocset["COMPUTER"].keys():
# result_solu = np.zeros((SOLUTION.shape[1], self.modelinfo["coord"].shape[0], 3))
# for ns in range(SOLUTION.shape[1]):
# result_solu[ns, :, :], sol_title = setPostProcess.__displ(self, SOLUTION[:, ns])

if "modes" in postprocset["COMPUTER"]["structural"].keys():
FREQUENCY = postprocset["SOLVERDATA"]["solution"]["FREQ"]
Expand All @@ -112,7 +107,13 @@ def getCompute(self, postprocset):
),
"avr": True,
}
)
)

postprocdata['SOLUTION'].append({'VAL':result_solu[st, :, :],
'MODE':st+1,
"FREQ":np.round(FREQUENCY[st][2], 3)
})

if (
"frf" in postprocset["COMPUTER"]["structural"].keys()
and postprocset["COMPUTER"]["structural"]["frf"] == True
Expand All @@ -132,13 +133,17 @@ def getCompute(self, postprocset):
"avr": True,
}
)

postprocdata['SOLUTION'].append({'VAL':result_solu[st, :, :],
"FREQ":np.round(FREQUENCY[st], 3)
})
else:
pass

if "thermal" in postprocset["COMPUTER"].keys():
result_solu = np.zeros((SOLUTION.shape[1], self.modelinfo["coord"].shape[0], 1))
for ns in range(SOLUTION.shape[1]):
result_solu[ns, :, :], sol_title = setPostProcess.__displ(self, SOLUTION[:, ns])
for st in range(SOLUTION.shape[1]):
result_solu[st, :, :], sol_title = setPostProcess.__displ(self, SOLUTION[:, st])
if "temp" in postprocset["COMPUTER"]["thermal"].keys():
postporc_result["solution"] = []
for st in range(SOLUTION.shape[1]):
Expand All @@ -150,7 +155,8 @@ def getCompute(self, postprocset):
}
)

postprocdata[sol_title] = result_solu[st, :, :]
postprocdata['SOLUTION'].append({sol_title:result_solu[st, :, :],
'STEP':st+1})

if (
"heatflux" in postprocset["COMPUTER"]["thermal"].keys()
Expand All @@ -160,14 +166,12 @@ def getCompute(self, postprocset):
(
SOLUTION.shape[1],
self.modelinfo["inci"].shape[0],
2 * self.modelinfo["tensor"] + 4,
2 * self.modelinfo["tensor"] + 2,
)
)

for ns in range(SOLUTION.shape[1]):
result_stress[ns, :, :], title = setPostProcess.__stress(
self, SOLUTION[:, ns]
)
for st in range(SOLUTION.shape[1]):
result_stress[st, :, :], title = setPostProcess.__heatflux(self, SOLUTION[:, st])

postporc_result["stress_elm"] = []
for st in range(SOLUTION.shape[1]):
Expand All @@ -176,8 +180,7 @@ def getCompute(self, postprocset):
)

for setpost in range(result_stress.shape[2]):
postprocdata[title[setpost]] = result_stress[st, :, setpost]

postprocdata[title[setpost]] = result_stress[st, :, setpost]

else:
pass
Expand All @@ -194,7 +197,7 @@ def getTracker(self, postprocset, postporc_result):
hist_Y = []
plotset["nodedof"] = self.modelinfo["nodedof"]

max_steps = len(postporc_result["solution"])
max_steps = len(postporc_result['SOLUTION'])

# if 'frf' in postprocset["TRACKER"].keys():
# max_steps = len(postporc_result["frf"])
Expand Down Expand Up @@ -277,17 +280,18 @@ def __tovtkplot(self, postprocset, postporc_result):
and postprocset["COMPUTER"]["structural"]["stress"] == True
):
plotdata["stress_CELL_DATA_val"] = postporc_result["stress_elm"][st]["val"]
plotdata["stress_CELL_DATA_title"] = postporc_result["stress_elm"][st]["title"]

plotdata["stress_CELL_DATA_title"] = postporc_result["stress_elm"][st]["title"]
convert_to_vtk(plotdata)

elif "modes" in postprocset["COMPUTER"]["structural"].keys():
plotdata["modes_POINT_DATA"] = []
# plotdata["filename"] = (path + "/" + postprocset["PLOTSET"]["filename"] + "_results_modes")
plotdata["modes_POINT_DATA"] = postporc_result["solution"]
# plotdata["modes_POINT_DATA_title"] = postporc_result["solution"][st]["title"]

convert_to_vtk(plotdata)
convert_to_vtk(plotdata)

elif "frf" in postprocset["COMPUTER"]["structural"].keys():
plotdata["frf_POINT_DATA"] = []
plotdata["frf_POINT_DATA"] = postporc_result["solution"]
convert_to_vtk(plotdata)

elif "thermal" in postprocset["COMPUTER"].keys():

Expand Down Expand Up @@ -373,8 +377,7 @@ def __stress(self, U):
sigma, epsilon, self.modelinfo["elemvol"][ee]
)

FoS = 0.0
# FoS = self.model.material.getFailureCriteria(...)
FoS = self.model.material.getFailureCriteria(sigma)

stress_list[ee, :] = stress
strain_list[ee, :] = strain
Expand All @@ -388,13 +391,49 @@ def __stress(self, U):
tistrs = self.model.material.getTitleStress()
tistrn = self.model.material.getTitleStrain()
ticomp = self.model.material.getTitleCompliance()
tifos = ["FoS_YIELD_VON_MISES"] # self.model.material.getTitleFoS()
tifos = self.model.material.getTitleFoS()
title = np.concatenate((tistrs, tistrn, ticomp, tifos), axis=0)
return result, title


def __heatflux(self, U):
"""_summary_
# def __strain_energy(self, sigma, epsilon, elemvol):
# result = self.model.material.getStrainEnergyDensity(sigma, epsilon, elemvol)
# return result
Arguments:
U -- _description_
Returns:
_description_
"""
stress_list = np.zeros(
(self.modelinfo["nelem"], self.modelinfo["tensor"] + 1), dtype=float
)

strain_list = np.zeros(
(self.modelinfo["nelem"], self.modelinfo["tensor"] + 1), dtype=float
)

pt, wt = gauss_points(self.modelinfo["type_shape"], 1)
for ee in range(self.modelinfo["nelem"]):
epsilon, strain = self.model.material.getElementGradTemp(
self.model, U, pt, ee
)

sigma, stress = self.model.material.getElementHeatFlux(
self.model, epsilon, ee
)

stress_list[ee, :] = stress
strain_list[ee, :] = strain

result = np.concatenate(
(stress_list, strain_list), axis=1
)

tistrs = self.model.material.getTitleHeatFlux()
tistrn = self.model.material.getTitleGradTemp()
title = np.concatenate((tistrs, tistrn), axis=0)
return result, title

def __tracker_value(postporc_result, postprocset, plotset, coord):
"""trancker plot function"""
Expand All @@ -408,7 +447,7 @@ def __tracker_value(postporc_result, postprocset, plotset, coord):
)
# hist_node = hist_node[0]-1
# plotset["rstl"] = nodedof[0]*hist_node - (nodedof[0]-postprocset["TRACKER"]["data"]["displ"]["dof"])
val_Y = postporc_result["solution"][plotset["step"]]["val"][
val_Y = postporc_result["SOLUTION"][plotset["step"]]["val"][
hist_node[0] - 1, postprocset["TRACKER"]["point"]["dof"]
]
val_X = plotset["step"] + 1
Expand Down Expand Up @@ -456,14 +495,14 @@ def __tracker_value(postporc_result, postprocset, plotset, coord):
val_Y = 20 * np.log(
(
abs(
postporc_result["solution"][plotset["step"]]["val"][
postporc_result["SOLUTION"][plotset["step"]]["VAL"][
hist_node[0] - 1, postprocset["TRACKER"]["frf"]["dof"]
]
)
)
/ 10e-12
)
val_X = postporc_result["solution"][plotset["step"]]["freq"]
val_X = postporc_result["SOLUTION"][plotset["step"]]["FREQ"]
xlabel = "FREQUENCY RESPONSE [Hz]"
ylabel = "FREQUENCY RESPONSE [dB]"

Expand Down

0 comments on commit 73ca145

Please sign in to comment.