Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #50 - generates pvcell coeffs from iec 61853 #51

Merged
merged 23 commits into from
Mar 24, 2017

Conversation

mikofski
Copy link
Contributor

  • calculate iec 61853 from sandia perfmod

Signed-off-by: Mark Mikofski mark.mikofski@sunpowercorp.com

* calculate iec 61853 from sandia perfmod

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
@mikofski mikofski self-assigned this Mar 17, 2017
* need to use i_c = sympy.Function('i_c')('v_c') so that d/dVc (Ic) =
dIc/dVc
* change alpha-Isc in comments to alpha_Isc (underscore v dash)
* copy sandia2diode-python fdidv to
pvmismatch/contrib/diode/two_diode.py but no changes yet
* create test_didv in diode tests and copy sym_dIdV.m from the original
MATLAB Sandia2diode/+two_diode packagee

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* also fix indentation of PVMODULES dictionary
* also add test for derivatives of didv
* add logging to tests
* use Vmp and Imp for Vc and Ic in fvd tests
* change test_data to test_data1 and test_data2
* use Isc0, Imp0 and Vmp0 from PVMODULES in gen_coeffs
* move notes on derivative derivation in tests to more meaningful
location

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* jdidv has 2 terms and denom in 1st term is squared, oops!
* was comparing rs1 in test but rs2 in expected, oops!

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* get rid of all those ridiculous underscores, so many underscores

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* the MATLAB Sandia2Diode code for d(dpdv) had an error because dpdv =
didv * vc + ic, but MATLAB wasn't aware that ic = f(vc) so it was
missing didv derivatives, oops!
* add test for dpdv and its derivatives
* add newer version of fdpdv with fix
* also update some module docstrings

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* don't use jacobian
* add residual_two_diode to gen_coeffs
* add constants to diode
* add other diode functions like Isat(T) cubic relation and Isc(T) with
linear tempco alpha_isc and how to solve for photogen coefficient to
make short circuit and photogen proportionality true (aka aph)
* use diode equations in derivatives
* use sympy for fjrsh
* start to derive and test derivatives for shunt equation

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* move gen_coeff.py to gen_coeff/ and diode/ to gen_coeff/diode.py
* only use hybridj solver (fsolve) for now, since lm is sucky w/o
derivatives
* turns out everything is sucky without derivatives
* change fjrsh from rsh + 1/didv to vd(1/rsh + didv) so units are in
amps just like other residuals, where vd = isc*rs therefore vd/rsh = ish
* add weights parameter, default is 1.0

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
* fix bug, remove ee from iph, since isc is already scaled to ee
* change args, use imp more intuitive order, remove ee from args
* fix jacobian stacking for levenberg-marquardt problems
* remove weights, and allow args and kwargs to pass to solver

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
@mikofski
Copy link
Contributor Author

@bmeyers this is ready for review for like a release candidate release. Can you take a quick look and let me know if you think it's okay to merge and release as v3.1rc1? Don't worry about the ugly jacobian expressions, they were generated by sympy, but I didn't simplify them at all, takes too much time and the calculation savings is in μs. Their validity is checked in the tests, so if you're inclined you can validate the sympy expressions.

I won't work any more on this for awhile, but it is good enough to use with PVMismatch the way that PVMismatch is currently implemented, IE: with 2-diode model and no irradiance modification of either Isat2 or Rsh.

Unfortunately the errors of off-STC conditions vary widely between module types. This will be resolved by switching to either CEC or PVSyst model or by adding modifiers to either Rsh, Isat2 or both.

The gen_coeff methods can be used with arrays of input if the optimizer method is set to 'lm', or input at any (irr, tc) condition using the default 'hbrj' solver. Generating coefficients over the entire IEC61853 matrix do confirm that Isat1 and Rs are constant for all (irr, tc), but Isat2 and Rsh vary with irradiance.

The next time we visit this, we should look into resolving the irradiance dependence of Isat2 and Rsh.

@bmeyers
Copy link
Contributor

bmeyers commented Mar 24, 2017

@mikofski taking a look now. looks like a lot of work!

d_m = np.atleast_1d(vd_isat_growth / (m ** 2.0 * vt)) # df w.r.t. m
d_vt = np.atleast_1d(vd_isat_growth / (m * vt ** 2.0)) # df w.r.t. vt
jac = np.array([d_isat, d_vd, d_m, d_vt]) # jacobian
return id_, jac
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 math checks out

@mikofski mikofski merged commit ee3379a into SunPower:master Mar 24, 2017
@mikofski mikofski deleted the gen_diode branch March 24, 2017 01:15
@bcbourne
Copy link

bcbourne commented Mar 24, 2017 via email

@mikofski
Copy link
Contributor Author

@BenBourne unfortunately, the generated 2-diode coefficients have two issues:

  1. The 2-diode model as implemented (without irradiance modifiers for Rsh and Isat2) do not fit all of the data well. In particular there are errors at low temperature and high temperature. The errors vary from module to module. EG for P series the errors were smaller than for E series.
  2. The 2-diode model as implemented fits better when only STC values are used. When all IEC61853 measurements are used, the variaitions in Rsh and Isat2 are too large to be fit by a common set of parameters for the entire range of IEC61853. In order to fit the entire range we will have to either:
    • use irradiance modifiers with either Rsh, Isat2 or both
    • switch to either CEC or PVSyst model

This is as good as we can get it for right now. When we have time to revisit this, and improve the models to reduce the error. For now I think this PR satisfies the need to provide PVMismatch parameters at STC for any module in the SAPM database.

P-series (fit with only STC measurments)

pvmismatch_gen_p17-345w_coeffs

E-series (fit with only STC measurments)

pvmismatch_gen_coeffs

inv_delta_t = 1.0 / t0k - 1.0 / tck # [1/K]
exp_tstar = np.exp(EG * QE / KB * inv_delta_t)
isat_t = isat0 * tstar * exp_tstar
return isat_t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this equation. Do you mind sending me a reference so I can get up to speed?

@bmeyers
Copy link
Contributor

bmeyers commented Mar 24, 2017

Excellent work, Mark!

@mikofski
Copy link
Contributor Author

mikofski commented Mar 24, 2017

For cubic dependence of Isat1 see

Also in tests with data for PVLife the first diode in two diode model fits this relation very close. In only one diode model doesn't fit as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants