SciML / SciML/DiffEqCallbacks.jl

[FR] Allow for user defined `u` in `PositiveDomain`

Open
#228 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
100
Forks
54
Avg merge
3h 29m
Merged PRs (30d)
8

Description

Is your feature request related to a problem? Please describe.

I'd like to use the PositiveDomain callback, but only for a specific subset of u. Specifically, in our case u is a ComponentVector of which only a single variable must not be negative.

Describe the solution you’d like

As stated in the docstring of PositiveDomain, one can provide their own function for isoutofdomain: isoutofdomain=(u,p,t) -> any(x -> x < 0, u) (we use any(x -> x < 0, u.storage). Likewise, I would suggest to provide a similar method to PositiveDomain to retrieve the user specific u. That could be PositiveDomain(...; u_getter=(u,p,t) -> u), but probably using a better keyword name.

Describe alternatives you’ve considered

Diving into the code it seems we could override isaccepted by dispatching on a specific type of u, but that would be piracy of internal methods. A user defined isaccepted instead of only a u_getter could work, but would come closer to a GeneralDomain.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PositiveDomain docstring and its existing isoutofdomain behavior, then inspect the related isaccepted dispatch mentioned in the issue. Clarify the keyword/API design for retrieving a user-specific part of u, define how it should work with ComponentVector, and add coverage showing the requested subset is checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.