Spaces:
Sleeping
Sleeping
Update src/visualization.py (#76)
Browse files- Update src/visualization.py (8cb4c5952d60d80f2059c9798b6481e57e0578f6)
Co-authored-by: Axel Rousseau <axelrvite@users.noreply.huggingface.co>
- src/visualization.py +7 -3
src/visualization.py
CHANGED
|
@@ -645,8 +645,12 @@ class SolarCellVisualizer:
|
|
| 645 |
"nVth": [0.8*Vth, 3*Vth],
|
| 646 |
"J0": [1e-20, 1e-5],
|
| 647 |
}
|
| 648 |
-
|
|
|
|
|
|
|
|
|
|
| 649 |
print("Jph", abs(I[0]))
|
|
|
|
| 650 |
|
| 651 |
if params_to_fit["Jph"] > 0:
|
| 652 |
low_bounds = [bounds["Rsh"][0],bounds["Rs"][0], bounds["nVth"][0], bounds["J0"][0], params_to_fit["Jph"] * 0.9]
|
|
@@ -657,13 +661,13 @@ class SolarCellVisualizer:
|
|
| 657 |
#print("low_bounds", low_bounds)
|
| 658 |
#print("high_bounds", high_bounds)
|
| 659 |
|
| 660 |
-
#
|
| 661 |
params_to_fit["Rsh"] = min(max(params_to_fit["Rsh"], bounds["Rsh"][0]), bounds["Rsh"][1])
|
| 662 |
params_to_fit["Rs"] = min(max(params_to_fit["Rs"], bounds["Rs"][0]), bounds["Rs"][1])
|
| 663 |
params_to_fit["nVth"] = min(max(params_to_fit["nVth"], bounds["nVth"][0]), bounds["nVth"][1])
|
| 664 |
params_to_fit["J0"] = min(max(params_to_fit["J0"], bounds["J0"][0]), bounds["J0"][1])
|
| 665 |
|
| 666 |
-
popt, pcov = curve_fit(iv_curve, V,
|
| 667 |
p0=list(params_to_fit.values()), bounds=(low_bounds, high_bounds), maxfev=10000)
|
| 668 |
param_fit = { "Rsh": popt[0],
|
| 669 |
"Rs": popt[1],
|
|
|
|
| 645 |
"nVth": [0.8*Vth, 3*Vth],
|
| 646 |
"J0": [1e-20, 1e-5],
|
| 647 |
}
|
| 648 |
+
if I[0]<I[-1]:
|
| 649 |
+
I["I"] = -I["I"]
|
| 650 |
+
|
| 651 |
+
params_to_fit["Jph"]= I[0]
|
| 652 |
print("Jph", abs(I[0]))
|
| 653 |
+
|
| 654 |
|
| 655 |
if params_to_fit["Jph"] > 0:
|
| 656 |
low_bounds = [bounds["Rsh"][0],bounds["Rs"][0], bounds["nVth"][0], bounds["J0"][0], params_to_fit["Jph"] * 0.9]
|
|
|
|
| 661 |
#print("low_bounds", low_bounds)
|
| 662 |
#print("high_bounds", high_bounds)
|
| 663 |
|
| 664 |
+
# Ajustemexnt automatique des paramètres s'ils dépassent les bornes
|
| 665 |
params_to_fit["Rsh"] = min(max(params_to_fit["Rsh"], bounds["Rsh"][0]), bounds["Rsh"][1])
|
| 666 |
params_to_fit["Rs"] = min(max(params_to_fit["Rs"], bounds["Rs"][0]), bounds["Rs"][1])
|
| 667 |
params_to_fit["nVth"] = min(max(params_to_fit["nVth"], bounds["nVth"][0]), bounds["nVth"][1])
|
| 668 |
params_to_fit["J0"] = min(max(params_to_fit["J0"], bounds["J0"][0]), bounds["J0"][1])
|
| 669 |
|
| 670 |
+
popt, pcov = curve_fit(iv_curve, V, I,
|
| 671 |
p0=list(params_to_fit.values()), bounds=(low_bounds, high_bounds), maxfev=10000)
|
| 672 |
param_fit = { "Rsh": popt[0],
|
| 673 |
"Rs": popt[1],
|