跳到正文
FunCoding

define-domains

Create and manipulate domains for PINA physics-driven problems. Covers domain types (Cartesian, Ellipsoid, Simplex), set operations, partial/update methods, and domain discretisation.

Star
804
分类
科研
许可证
MIT
最近提交
2026年12月1日

.opencode/skills/define-domains/SKILL.md

在 GitHub 上查看

Define Domains for a PINA Problem

Important

Read RULES.md before using this skill — it applies to all skills. This is a sub-skill of create-problem. Load the entry-point skill first.

Use this skill to create spatial, temporal, and parameter domains, and to discretise them for training.

Step 1 — Create domains

For each domain type, ask:

What are the variable names and their ranges?

If the user does not specify a domain, ask for:

  1. Variable name (e.g. x)
  2. Lower bound (e.g. 0)
  3. Upper bound (e.g. 1)

Domain types available

from pina.domain import CartesianDomain, EllipsoidDomain, SimplexDomain
Domain typeDescriptionExample
CartesianDomainHyperrectangle (most common)CartesianDomain({"x": [0, 1], "y": [0, 1]})
EllipsoidDomainHyperellipsoidEllipsoidDomain({"x": [0, 1], "y": [0, 1]})
SimplexDomainSimplex defined by verticesSimplexDomain(vertices=[...])

CartesianDomain supports sampling modes: random, grid, chebyshev, latin/lh.

Set operations on domains

from pina.domain import Union, Intersection, Difference, Exclusion

combined = Union(domain_a, domain_b)
overlap = Intersection(domain_a, domain_b)
subtracted = Difference(domain_a, domain_b)
excluded = Exclusion(domain_a, domain_b)

Step 2 — Domain methods for problem setup

partial() — extract boundary

Creates a sub-domain representing the boundary of the parent domain:

spatial_domain = CartesianDomain({"x": [0, 1], "y": [0, 1]})
boundary = spatial_domain.partial()  # boundary of the square

update() — combine domains (space + time)

Creates the Cartesian product of two domains. Essential for space-time problems:

spatial_domain = CartesianDomain({"x": [-1, 1]})
temporal_domain = CartesianDomain({"t": [0, 1]})

interior = spatial_domain.update(temporal_domain)
# Equivalent to CartesianDomain({"x": [-1, 1], "t": [0, 1]})

Common patterns:

domains = {
    "D": spatial_domain.update(temporal_domain),   # space-time interior
    "ic": spatial_domain.update(CartesianDomain({"t": 0})),  # initial condition
    "boundary": spatial_domain.partial().update(temporal_domain),  # moving boundary
}

Step 3 — Discretise domains (sampling)

After the problem class is fully defined, sample points from each domain:

problem.discretise_domain(n=5000, mode="random", domains=["D"])
problem.discretise_domain(n=500, mode="random", domains=["boundary"])
ModeDescription
"random"Uniform random sampling (default)
"latin"/"lh"Latin hypercube sampling
"grid"Regular grid points
"chebyshev"Chebyshev nodes (good for polynomials)

After all domains are discretised:

problem.move_discretisation_into_conditions()
assert problem.are_all_domains_discretised

Checklist

  • All required domains are defined (spatial_domain, temporal_domain, parameter_domain, or unknown_parameter_domain as appropriate)
  • domains dict contains a key for every domain referenced in conditions
  • For space-time problems: spatial_domain.update(temporal_domain) used to build the interior domain
  • For boundary conditions: spatial_domain.partial() used correctly
  • problem.discretise_domain(n=..., mode=..., domains=...) called for each physics domain
  • problem.move_discretisation_into_conditions() called before training
  • problem.are_all_domains_discretised is True after discretisation

相似的 Skill

graphify

GRGraphify-Labs/graphify156k近 7 天新增 2,564 个 star

wiki-query

PApaperclipai/paperclip119k近 7 天新增 1,966 个 star

官方

clinical-case-report

NEnexu-io/open-design111k近 7 天新增 1,277 个 star

style-sampling

HEheygen-com/hyperframes94k近 7 天新增 4,558 个 star

academic-paper-review

BYbytedance/deer-flow86k近 7 天新增 276 个 star

systematic-literature-review

BYbytedance/deer-flow86k近 7 天新增 276 个 star