pvlib-python icon indicating copy to clipboard operation
pvlib-python copied to clipboard

Add decomposition model to Modelchain suite

Open ramaroesilva opened this issue 1 month ago • 2 comments

Is your feature request related to a problem? Please describe. Modelchain does not include the decomposition step, forcing it to be done outside/before the modelchain.

Describe the solution you'd like Modelchain could allow decomposition as an optional parameter. By default it could be None, keeping the current demand for users to include dhi and dni in the weather data. But if not None only ghi would be asked.

Additional context I understand that having it as optional allows users to implement their own custom decomposition if they want. Similar to the run_model_from_poa option for users to ingest their own modelled or measured poa data.

ramaroesilva avatar Oct 21 '26 10:10 ramaroesilva

I'd like to work on this. Here's the approach I have in mind, to check before opening a PR.

A decomposition_model string keyword on ModelChain, like transposition_model, with default None:

mc = ModelChain(system, location, decomposition_model='erbs')
mc.run_model(weather)  # weather only needs 'ghi'

In prepare_inputs, right after the solar position step, if the weather has ghi but neither dni nor dhi, it calls model(ghi, solar_position['zenith'], times) and adds dni and dhi to results.weather. With None, nothing changes.

https://github.com/pvlib/pvlib-python/blob/c5de586d73bbb8875a4e87468894e7b34871a575/pvlib/modelchain.py#L1386-L1389

I tried it locally. It's about 30 lines in modelchain.py. With GHI-only weather, run_model gives the same AC output as running erbs by hand and passing all three columns. Per-array weather tuples work too.

Questions:

  1. Start with erbs, erbs_driesse, boland, louche and orgill_hollands? They return both DNI and DHI. disc and dirint only return DNI (#2865).
  2. Strings only, with no model kwargs for now? Or should it also accept a function, like aoi_model?
  3. If the weather already has dni and dhi, I use them as given. If only one is there, I kept the current error. Is that right?
  4. Should this use get_irradiance_components from #2850 instead of its own lookup?

It touches the same part of prepare_inputs as #2847, so I can wait for that and rebase.

AI disclosure: I used Claude Code (an AI coding agent) to read the code and prototype this approach.

aarmens702-hub avatar Nov 03 '26 18:11 aarmens702-hub

@aarmens702-hub please do not open a PR. This idea needs to be discussed and agreed upon before going forward.

kandersolar avatar Nov 04 '26 19:11 kandersolar