Repository navigation
Description
I'm proposing to add capability to model more than one array in a PV system. Defining the term "array", I mean a collection of PV modules at the same orientation (tilt and azimuth). Many actual PV systems have several arrays, distinguished by different orientation and/or number of modules and strings of modules.
The current PVSystem defines the DC side of a PV system using modules_per_string and strings_per_inverter and applies attributes surface_tilt and surface_azimuth to all modules. A PV system may have a single inverter. This model implicitly describes a PV system with a single array.
@wholmgren have discussed this a bit offline and think a way forward would be to make PVSystem attributes iterable. For example, surface_tilt could contain a list or array, with each element being an array of tilts to be applied to one of the arrays comprising the PV system. PVSystem and ModelChain methods would be extended to perform calculations for each array in the PV system, broadcasting where needed.
Two principles guiding this proposal:
- maintain the current interface for modeling systems with a single array. It is simple but effective, and modeling a single array system shouldn't become more complicated.
- methods should return the type indicated by the input attributes, so that a user doesn't need to deal with lists of length 1 when modeling a single array system.
We discussed, and disfavor other approaches:
- a new class for PV systems with multiple arrays, which not appealing when considering the duplication of code, and the likely complication of
ModelChainmethods. - subclassing
PVsystemor adding attributes, either of which look to be confusing for users.
Open for comments here, before I start a branch to work on this feature.
#457 is relevant. Having multiple arrays lays the groundwork for modeling inverters with multiple MPPTs.
Activity
cwhanse commentedon Sep 23, 2020
Exploring this a bit, to settle on a pattern, using a copy of the
PVSystem.get_aoimethod:This runs with
PVSystem.surface_tiltas an int, float, Series or array, withPVSystem.surface_azimuthof the same type and dimension. Discovered some challenges:Serieswith index taken from the inputsolar_zenithandsolar_azimuthSeries. The above function maintains that behavior if thesurface_tiltis a singleton or Series with the same index assolar_zenithandsolar_azimuth, but returns a 2D ndarray ifsurface_tiltis any other kind of iterable.PVSystem.surface_tiltcan arrive as a time-indexed Series for a single array on a tracked system. This implies that we would need to restrictPVSystem.surface_tilttosurface_tilt: float or arrayrather thansurface_tilt: float or array-like, because if surface_tilt is a Series of tilt indexed by the arrays, then the code still runs but the returnedaoiis garbage (see *)intnorfloatare interable.surface_tiltis an array butsurface_azimuthis a float, if not using a complicated sequence ofif isinstancestatements. If this is needed, there's got to be a better way.pvlib.irradiance.aoi_projectionuses the*operator rather than the pandasmultiplymethod. When the factors are Series with different indexes, for the product pandas merges the indexes and fills in nan for indices that aren't in both indexes. This result is not what a user would expect to see.wholmgren commentedon Sep 24, 2020
It might simplify things if we said PVSystem could accept any iterable of tilt or azimuth but coerce it into a standard type. For example
The following behavior is relevant:
Two things to try:
aoi_projection.SingleAxisTracker.get_aoimethod, changeaoi(surface_tilt,...) toaoi(surface_tilt.to_numpy(),...`cwhanse commentedon Sep 24, 2020
It would simplify the typing, but I think we have to resolve the overloading of
PVSystem.surface_tiltfirst.PVSystem.surface_tiltis an iterable of N tilts, one for each array.PVSystem.surface_tiltwould be an iterable of length N, each element of which is a Series.Perhaps a way forward is to use
if PVSystem.axis_tilt:to decide how to resolve the ambiguous case whenPVSystem.surface_tiltis a Series for a PV system with a single array with tracking.wholmgren commentedon Sep 24, 2020
I'm a little confused...
That's a
SingleAxisTracker, which can and does reimplementPVSystemmethods as needed to deal with these complexities.cwhanse commentedon Sep 24, 2020
Aha.
PVSystem.get_aoineeds only handle fixed tilt cases, becauseSingleAxisTrackerwill handle the tracker cases. I'm tracking now.mikofski commentedon Sep 25, 2020
broadcastnate-croft commentedon Sep 25, 2020
Just as another idea at risk of disrupting this line of thought. Have you considered creating a new type of "Multi Array ModelChain" that could implement and iterate through multiple ModelChains, instead of changing anything with
PVsystem? My thinking is that users who usePVsystemtypically only need it for single types of arrays given it can only have a single inverter anyway, and if they need multiple sub-arrays they've already built that out of multiple PVSystems. Thus the needs for multiple sub-arrays are likely going to beModelChainusers.A multiple array ModelChain could accept a single location, an iterable of multiple
PVsystemparameters, single inputs forModelChainparameters, and an iterable of 'inverters_per_system'. The class would then create a list of multiplePVsystemand multipleModelChainand could have a function to run_model on a weather input that would run each of its sub_models, multiply the ac outputs for the number of inverters of each system, and sum the outputs.The benefit here would be that all the underlying code could be left as is and I think it would be a relatively simple to implement. But this it would be more of an approach of adding a new wrapper around what is already there rather than building functionality from the bottom-up.
So it could be something like
multiarraysystem = pv.modelchain.MultiArrayModelChain(Location, system_parameters, inverters_per_array, **model_chain_parameters)where system parameters is a list of dicts and inverters_per_array is a list of integers, and when it initializes is creates unique instances of PVsystem for each dict in the list and also creates instances of ModelChains with them. Then a function like
multiarraysystem.run_model()would run the model for each sub-chain and add them together for one output.mikofski commentedon Sep 26, 2020
@ncroft-b4 interesting idea, but I think @cwhanse is trying to address subarrays that are connected to the same inverter or to different inputs of a multi-mppt inverter (see #457 )
mikofski commentedon Sep 26, 2020
Possibly relevant to OpenPVspec and #96
adriesse commentedon Sep 26, 2020
Or how about using a subarray as a building block and creating a multi-subarray inverter?
cwhanse commentedon Sep 27, 2020
@adriesse I'm not understanding your suggestion - can you elaborate?
@ncroft-b4 That's a thought... @mikofski the system I have in mind is one inverter with several non-identical DC arrays. @ncroft-b4 is right that the
PVSystemattributes I'm taking up here would not address the case of a system with several inverters with different arrays.mikofski commentedon Sep 27, 2020
Although several systems connected to different inverters is trivial, just calculate each separately. We don't have any ac post processes. So the most pressing case is the one you and I both describe:
adriesse commentedon Sep 28, 2020
It's hardly a fully thought-out idea. It just seems a System class could get quite complex as it grows to accommodate more and more types of systems. Perhaps a Subarray class could help to make it more modular.
cwhanse commentedon Sep 28, 2020
@wholmgren and I discussed an
Arrayclass, we haven't ruled it out. I think we are hoping that iterablePVSystemattributes may do the same job.wholmgren commentedon Sep 28, 2020
I thought that supporting iterable
PVSystem.surface_tiltandPVSystem.surface_azimuthcould be a relatively easy way to extendPVSystemcapabilities without greatly complicating the API. I agree that the approach would quickly become complex if we extended the support to additional attributes/parameters.Along with a new
Arrayclass, we also considered a redesign of thePVSystemclass. ThePVSystemredesign might be implemented as a new class rather than a modification to the existing class. If you were starting with a blank file, what would yourArrayandPVSystemclasses look like?5 remaining items
cwhanse commentedon Sep 28, 2020
array_likeworks but only whensurface_tiltetc. are of the same shape as any time-series input, e.g.,solar_zenithherewholmgren commentedon Sep 28, 2020
What about an
Arraywith a small number of attributes:surface_tiltsurface_azimuthmodule_parameterstemperature_model_parametersracking_modelalbedoand methods:
get_aoiget_irradianceget_iamso that a higher level object like
PVSystemcan do more complicated things? I don't want to embark on a big redesign only to find that we've locked ourselves out of system design and operation that become far more common over the next 5 years (PVSystem is currently 5 years old).Is the motivation for this just API compatibility with the existing
PVSystem? I'm not too worried about that at this point in the discussion.nate-croft commentedon Sep 28, 2020
Yes, but also to maintain a single object that fully represents a system that continues to work with
ModelChain. If Array is internal toPVSystemthen I don't think anything would need to change inModelChain, but ifArraygets split fromPVSystemthenModelChainwill have to run bothArraymethods andPVSystemmethods, wouldn't it?Though if it is not too big a deal to maintain current API compatibility with
PVsystem,then probably the ideal way would be to haveArray, then havePVSystemaccept one or moreArrayas input and expose theArraymethods asPVsystemmethods. Then maintaining ModelChain as is.wholmgren commentedon Sep 28, 2020
This is how I'm thinking about it.
If, in addition to an
Arrayclass, we end up creating a newPVSystemVersion2class (with a better name!) then perhapsModelChaininternals would support bothPVSystemandPVSystemVersion2for some period of time.cwhanse commentedon Sep 29, 2020
Or have
PVSystemaccept the inputs as iterables andPVSystemconstructs theArrays? May not be workable but preserves the current interface.I'm happy to mock up some code for one of the
Arrayoptions:Arrayclass,PVSystemexpects anArrayinput, other currentPVSysteminputs stay. This risks havingArrayand other inputs be inconsistent.Arrayclass, currentPVSysteminputs are rolled into theArrayclass with deprecation.Arrayclass, not an input toPVSystem, but constructed from currentPVSysteminputs.Any other options to consider, and which would be your preference?
wholmgren commentedon Sep 29, 2020
Of those options, I would start with 1 or 2. It could be that we ultimately support 3 but I don't think it's worth considering as part of the initial design.
I strongly feel that we need to think about a new
PVSystemclass in addition to a newArrayclass. The existingPVSystemclass is a confusing mixture of API design and forcing a newArrayinto this interface likely will lead to an unsatisfying local maximum in API design. By "new"PVSystemI mean a class for which it's not possible to cleanly deprecate from the current state ofPVSysteminto a new state. #1067 (comment) has some concrete suggestions for what theArraypart could look like.If we don't have the appetite for achieving consensus on a bigger redesign then I'd advocate for a simple solution that casts input iterables to arrays and exploits broadcasting.
cwhanse commentedon Sep 29, 2020
I'm OK with a "new" and redesigned
PVSystemclass, but I haven't come up with a name to propose...adriesse commentedon Sep 29, 2020
I think I like the direction the discussion is going.
The motivation for an Array class is to be able to do interesting things with more than one of them having different parameters or operating conditions. The two main cases seem to be (1) connecting them to different MPPT's on the same inverter, and (2) connecting them in parallel to the same MPPT.
(1) could be done with a new two-stage inverter efficiency model, but needs nothing new on the Array side. This doesn't seem hard to implement, but would just require some reasonable assumptions about the attribution of total internal losses. The same quadratic loss model can be used to model both conversion stages (with different parameter of course).
(2) requires combining I-V curve characteristics of the two or more arrays. This seems more well-defined, but perhaps a bit harder to implement. I would shy away from short-cuts like weighted average of Vmp though.
cwhanse commentedon Oct 5, 2020
Summarizing some offline conversations for the benefit of all. It seems we are converging to the following pattern:
Arrayclass with a small list of attributes and methods as suggested hereArrayinstance has a single value of tilt, azimuth, etc.PVSystemwill have a newarraysattribute that is assigned a list ofArrayinstances.PVSystemmethods will be modified to operate on elements ofPVSystem.arrays. The use of list here is deliberate so that the following works regardless of the length of self.arraysPVSystem.surface_tiltwill remain (for a deprecation period), andPVSystem.__init__will handle conversion of e.g.PVSystem.surface_tiltto an instance ofArrayassigned toPVSystem.arrays[0]. That way, old user code should still work, except for the case where a user was passing an array toPVSystem.surface_tiltand somehow getting away with it.I still need to look uphill to
ModelChain, where I'm thinking there will be substantial changes in that the attributes recording output of modeling steps may become lists e.g.ModelChain.dcis no longer a Series, it is a list of Series. Might be a more elegant way to handle that.This pattern meets the use case of a PV system with multiple arrays, with each array connected to a separate MPPT on one system-wide inverter. Follow-on work can extend this pattern to a PV system with one inverter per array.
The case of multiple arrays feeding one inverter without separate MPPT is not addressed, but isn't ruled out by this pattern. This case would require a new function to compute DC current and voltage at the inverter input, and it's not clear how that should be done (Kirchoff's laws of course, but, one likely needs parameters that aren't already in pvlib).
@wfvining fyi
wfvining commentedon Oct 6, 2020
Where will
Arraylive? Should it go in thepvlib.pvsystemmodule?cwhanse commentedon Oct 6, 2020
Good place for now.