Skip to content

Commit

Permalink
Merge pull request #28 from NREL/termVolt
Browse files Browse the repository at this point in the history
computer terminal voltage error as part of the stats
  • Loading branch information
malihass authored Apr 24, 2024
2 parents 1a259a8 + efd331a commit 47c11f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pinn_spm_param/postProcess/computeError.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def computeError(dataDict, predDict, debug=False):
abs(yTest_phis_c - phis_c_rescaled)
/ np.clip(abs(yTest_phis_c), a_min=1e-16, a_max=None)
)
term_volt = np.mean(abs(yTest_phis_c - phis_c_rescaled))
globalError += tmp
globalError_phis_c = tmp
if debug:
Expand Down Expand Up @@ -86,6 +87,7 @@ def computeError(dataDict, predDict, debug=False):
"phis_c": globalError_phis_c,
"cs_a": globalError_cs_a,
"cs_c": globalError_cs_c,
"term_volt": term_volt,
}


Expand Down
22 changes: 21 additions & 1 deletion pinn_spm_param/postProcess/computeManyMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def getManyFolders(rootFolder, prefix="LogFin"):
endError_cs_c = []
maxSteps = []
maxEpochs = []
endErrorTermVolt = []
for lossFolder in lossFolders:
fileGlobalLoss = os.path.join(rootFolder, lossFolder, "log.csv")
globMSELoss = readLoss(fileGlobalLoss)
Expand Down Expand Up @@ -118,6 +119,19 @@ def getManyFolders(rootFolder, prefix="LogFin"):
endError_phis_c.append(err_dict["phis_c"])
endError_cs_a.append(err_dict["cs_a"])
endError_cs_c.append(err_dict["cs_c"])
endErrorTermVolt.append(err_dict["term_volt"])

ptile1 = 2.5
ptile2 = 97.5
errptile = [
np.percentile(np.array(endError), ptile1),
np.percentile(np.array(endError), ptile2),
]
errTVptile = [
np.percentile(np.array(endErrorTermVolt), ptile1),
np.percentile(np.array(endErrorTermVolt), ptile2),
]


print(
f"Loss {np.mean(np.array(endMSELosses)):.2f} +\- {np.std(np.array(endMSELosses)):.2f}"
Expand All @@ -126,7 +140,13 @@ def getManyFolders(rootFolder, prefix="LogFin"):
f"Error {np.mean(np.array(endError)):.2f} +\- {np.std(np.array(endError)):.2f}"
)
print(
f"Error med {np.median(np.array(endError)):.2f} ptiles {np.percentile(np.array(endError), 2.5):.2f} +\- {np.percentile(np.array(endError), 97.5):.2f}"
f"Error med {np.median(np.array(endError)):.2g} ptiles {errptile[0]:.2g} +\- {errptile[1]:.2g}"
)
print(
f"Term volt {np.mean(np.array(endErrorTermVolt)):.2g} +\- {np.std(np.array(endErrorTermVolt)):.2g}"
)
print(
f"Term volt med {np.median(np.array(endErrorTermVolt)):.2g} ptiles {errTVptile[0]:.2g} +\- {errTVptile[1]:.2g}"
)
print(
f"\tphie {np.mean(np.array(endError_phie)):.2f} +\- {np.std(np.array(endError_phie)):.2f}"
Expand Down

0 comments on commit 47c11f2

Please sign in to comment.