Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronakshoghi committed Dec 11, 2023
2 parents c44b3be + 9e5a617 commit f00e863
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 231 deletions.
14 changes: 9 additions & 5 deletions examples/data_6d/Data_6D_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def find_yloc(x, sunit, epl, mat):


# Import Data
db = FE.Data("Data_Base_Updated_Final_Rotated_Train.JSON", wh_data=True)
db = FE.Data("Data_Base_Updated_Final_Rotated_Train.json", wh_data=True)
# db = FE.Data("Data_Base_UpdatedE-07.json", Work_Hardening=False)
# define reference material, J2 plasticity, linear w.h.
mat_ref = FE.Material(name="reference")
Expand All @@ -37,12 +37,13 @@ def find_yloc(x, sunit, epl, mat):
print(f'Successfully imported data for {db.mat_data["Nlc"]} load cases')
mat_ml = FE.Material(db.mat_data['Name'], num=1) # define material
mat_ml.from_data(db.mat_data) # data-based definition of material
"""

# Train SVC with data from all microstructures
mat_ml.train_SVC(C=1, gamma=0.5, Fe=0.7, Ce=0.9, Nseq=2,
mat_ml.train_SVC(C=2, gamma=0.1, Fe=0.89, Ce=0.9, Nseq=1,
gridsearch=False, plot=False)
print('Training successful.\n' +
f'Number of support vectors: {len(mat_ml.svm_yf.support_vectors_)}')
mat_ml.export_MLparam(__file__, file='abq_data-C2-g01-Fe89-Ce9-N1', path='./')

# Testing
sig_tot, epl_tot, yf_ref = CTD.Create_Test_Sig(
Expand Down Expand Up @@ -168,8 +169,9 @@ def find_yloc(x, sunit, epl, mat):
legend.legendHandles[1]._sizes = [50]
plt.tight_layout()
fig.savefig('Reconstructed_Stress_Strain_Curve.png', dpi=300)
plt.show()"""
plt.show()

"""
# Analysis of level of smoothness of the ML yield function using the gradient
# of the yield function
print('Repeating training for 4 combinations of hyperparameters.')
Expand Down Expand Up @@ -256,4 +258,6 @@ def find_yloc(x, sunit, epl, mat):
ax2.legend(fontsize=14)
ax2.tick_params(labelsize=14)
plt.tight_layout()
plt.show()
plt.show()
"""

17 changes: 12 additions & 5 deletions examples/data_6d/Stress_Strain_Calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,25 @@
import pylabfea as FE

# Import Data
db = FE.Data("Data_Base_Updated_Final_Rotated_Train.JSON", wh_data=True)
db = FE.Data("Data_Base_Updated_Final_Rotated_Train.json", wh_data=True)

# db.plot_yield_locus(db=db, mat_data=db.mat_data, active='flow_stress')
print(f'Successfully imported data for {db.mat_data["Nlc"]} load cases')
mat_ml = FE.Material(db.mat_data['Name'], num=1) # define material
mat_ml.from_data(db.mat_data) # data-based definition of material

# Train SVC with data and plot resulting stress-strain curves for
# simple load cases
mat_ml.train_SVC(C=2, gamma=0.1, Fe=0.7, Ce=0.9, Nseq=1,
# Train SVC with data and plot yield locus
mat_ml.train_SVC(C=2, gamma=0.1, Fe=0.7, Ce=0.9, Nseq=2,
gridsearch=False, plot=False)
print(f'Training completed. Generated {len(mat_ml.svm_yf.support_vectors_)}' +
' support vectors.')
sc = FE.sig_princ2cyl(mat_ml.msparam[0]['sig_ideal'])
mat_ml.polar_plot_yl(data=sc, dname='training data', arrow=True)
# export ML parameters for use in UMAT
mat_ml.export_MLparam(__file__, file='abq_data-C2-g01-Fe7-Ce9-N2', path='./')

# Calculate and plot resulting stress-strain curves for
# simple load cases
print("\nCalculating stress-strain data. I'll be back!")
mat_ml.calc_properties(eps=0.02, sigeps=True)
mat_ml.calc_properties(eps=0.03, sigeps=True)
mat_ml.plot_stress_strain()
Loading

0 comments on commit f00e863

Please sign in to comment.