Skip to content

Commit

Permalink
KKS_OpenCL Update MicroSim 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Saurav Shenoy committed Jul 9, 2023
1 parent 37869f4 commit dda452f
Show file tree
Hide file tree
Showing 142 changed files with 24,361 additions and 8,583 deletions.
11 changes: 0 additions & 11 deletions KKS_OpenCl/FillingRandomppt.in

This file was deleted.

8 changes: 0 additions & 8 deletions KKS_OpenCl/Filling_GV.in

This file was deleted.

20 changes: 12 additions & 8 deletions KKS_OpenCl/Filling.in → KKS_OpenCl/Filling_isoT.in
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#FILLCUBE = {0, 10, 10, 0, 20, 20, 0};
#FILLCUBE = {0, 0, 0, 0, 100, 20, 0};
#FILLCUBE = {0, 10, 10, 0, 20, 20, 0};
##FILLCYLINDER = {phase, x_centre, y_centre, z_start, z_end, radius}
FILLCYLINDER = {0, 0, 0, 0, 0, 5};
###FILLELLIPSE = {phase, x_center, y_center, major_axis, eccentricity, rotation_angle_deg}
#FILLELLIPSE = {0, 50, 50, 0, 10, 0.1, 10};
#FILLSPHERE = {0, 50, 50, 0, 10};
#FILLCUBE = {0, 10, 10, 0, 20, 20, 0};
#FILLCUBE = {0, 0, 0, 0, 100, 20, 0};
#FILLCUBE = {0, 10, 10, 0, 20, 20, 0};
##FILLCYLINDER = {phase, x_centre, y_centre, z_start, z_end, radius}
#FILLCYLINDER = {0, 0, 0, 0, 0, 5};
#FILLCYLINDER = {0, 128, 128, 0, 0, 20};
###FILLELLIPSE = {phase, x_center, y_center, major_axis, eccentricity, rotation_angle_deg}
#FILLELLIPSE = {0, 50, 50, 0, 10, 0.1, 10};
FILLSPHERE = {0, 0, 0, 0, 10};
#FILLSPHERE = {1, 0, 5, 0, 10};
#FILLSPHERE = {2, 25, 0, 0, 10};
#FILLSPHERE = {3, 25, 50, 0, 10};
66 changes: 38 additions & 28 deletions KKS_OpenCl/GEdata_writer.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,39 @@
print("tdb_phases =", phases)
print("````````````````````````````````\n")


############################## Writing files for OpenCL #defines

nphadef = '#define npha (' + str(len(nphases)) + ')\n'
ncomdef = '#define ncom (' + str(len(components)) + ')\n'
nsoldef = '#define nsol (ncom-1)\n'
#nsoldef = '#define nsol (' + str(len(components-1)) + ')\n'

print(nphadef)
print(ncomdef)

file = open("solverloop/defines.h", "w")
file.write(nphadef)
file.write(ncomdef)
file.write(nsoldef)

# with fileinput.FileInput('solverloop/defines.h', inplace=True) as file:
# for line in file:
# if line.strip().startswith('#define npha ('):
# line = nphadef
# sys.stdout.write(line)


# with fileinput.FileInput('solverloop/defines.h', inplace=True) as file:
# for line in file:
# if line.strip().startswith('#define ncom ('):
# line = ncomdef
# sys.stdout.write(line)


###############################################################


#my_phases_tdb = ['LIQUID', 'FCC_A1']
### Reading in the .tdb files
tdbf = Database(tdbfname)
Expand Down Expand Up @@ -341,43 +374,21 @@ def generate_thermodynamic_files(tdbf, comps, phase):



nphadef = '#define npha (' + str(len(nphases)) + ')\n'
ncomdef = '#define ncom (' + str(len(components)) + ')\n'

#print(nphadef)
#print(ncomdef)

file = open("solverloop/defines.h", "w")
file.write(nphadef)
file.write(ncomdef)

# with fileinput.FileInput('solverloop/defines.h', inplace=True) as file:
# for line in file:
# if line.strip().startswith('#define npha ('):
# line = nphadef
# sys.stdout.write(line)


# with fileinput.FileInput('solverloop/defines.h', inplace=True) as file:
# for line in file:
# if line.strip().startswith('#define ncom ('):
# line = ncomdef
# sys.stdout.write(line)

#################### Writing thermo function calls for OpenCL

file = open("solverloop/GibbsEnergyData2.h", "w")
file.write("//Do not edit this file alone. Function calls in kerenls can go wrong if any changes are made...\n\n")
file.write("#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n\n")
file.write("void Ge(double T, double *y, double *Ge, int tpha);\n")
file.write("void Mu(double T, double *y, double *MU, int tpha);\n")
file.write("void dMudc(double T, double *y, double *Dmudc, int tpha\n);")
file.write("void dMudc(double T, double *y, double *Dmudc, int tpha);\n")
file.write("\n\n")
file.write("void Ge(double T, double *y, double *Ge, int tpha) { \n")

Ge_functions = "\n if ( tpha == 0 ) { \n " + " " + free_energy_tdb[0].name + "(T, y, Ge); \n }\n"

for i in range(1,len(phases)):
Ge_functions += " else if ( tpha == " + str(i) +" ) { \n"
Ge_functions += " else if ( tpha == " + str(i) +" ) { \n"
Ge_functions += " " + free_energy_tdb[i].name + "(T, y, Ge); \n }\n"

Ge_functions += "\n}\n\n"
Expand All @@ -388,7 +399,7 @@ def generate_thermodynamic_files(tdbf, comps, phase):
Mu_functions = "\n if ( tpha == 0 ) { \n " + " " + Mu_tdb[0].name + "(T, y, MU); \n }\n"

for i in range(1,len(phases)):
Mu_functions += " else if ( tpha == " + str(i) +" ) { \n"
Mu_functions += " else if ( tpha == " + str(i) +" ) { \n"
Mu_functions += " " + Mu_tdb[i].name + "(T, y, MU); \n }\n"

Mu_functions += "\n}\n\n"
Expand All @@ -399,10 +410,9 @@ def generate_thermodynamic_files(tdbf, comps, phase):
dMudc_functions = "\n if ( tpha == 0 ) { \n " + " " + dmudc_tdb[0].name + "(T, y, Dmudc); \n }\n"

for i in range(1,len(phases)):
dMudc_functions += " else if ( tpha == " + str(i) +" ) { \n"
dMudc_functions += " else if ( tpha == " + str(i) +" ) { \n"
dMudc_functions += " " + dmudc_tdb[i].name + "(T, y, Dmudc); \n }\n"

dMudc_functions += "\n}\n\n"

file.write(dMudc_functions)

127 changes: 0 additions & 127 deletions KKS_OpenCl/Input.in

This file was deleted.

Loading

0 comments on commit dda452f

Please sign in to comment.