ProblemInterface#
Module for the Problem Interface.
- class ProblemInterface[source]#
Bases:
objectAbstract interface for all problems.
- abstract discretise_domain(n=None, mode='random', domains=None, sample_rules=None)[source]#
Discretise the problem’s domains by sampling a specified number of points according to the selected sampling mode.
- Parameters:
n (int) – The number of points to sample. This is ignored if
sample_rulesis provided. Default isNone.mode (str) – The sampling method. Available modes include:
"random"for random sampling,"latin"or"lh"for latin hypercube sampling,"chebyshev"for Chebyshev sampling, and"grid"for grid sampling. Default is"random".domains (str | list[str]) – The domains from which to sample. If
None, all domains are considered for sampling. Default isNone.sample_rules (dict) – The dictionary specifying custom sampling rules for each input variable. When provided, it overrides the global
nandmodearguments. Each key in the dictionary must match one of the variables defined ininput_variables(), and each value must be a dictionary containing two keys:nfor the number of points to sample for that variable, andmodefor the sampling method to use. IfNone, the globalnandmodeparameters are used for all variables. Default isNone.
Warning
"random"is the only supportedmodeacross all geometries:CartesianDomain,EllipsoidDomain, andSimplexDomain. Sampling modes such as"latin","chebyshev", and"grid"are only implemented forCartesianDomain. When custom discretisation is specified viasample_rules, the domain to be discretised must be an instance ofCartesianDomain.- Example:
>>> problem.discretise_domain(n=10, mode="random") >>> problem.discretise_domain(n=10, mode="lh", domains=["boundary"]) >>> problem.discretise_domain( ... sample_rules={ ... 'x': {'n': 10, 'mode': 'grid'}, ... 'y': {'n': 100, 'mode': 'grid'} ... }, ... )
- abstract add_points(new_points_dict)[source]#
Append additional points to an already discretised domain.
- Parameters:
new_points_dict (dict) – The dictionary mapping each domain to the corresponding set of new points to be added. Each key in the dictionary must match one of the domains defined in
domains, and each value must be aLabelTensorcontaining the new points to be added to that domain. The labels of the points to be added must correspond to those of the domain to which they are being added.- Example:
>>> additional_points = { ... "boundary": LabelTensor(torch.rand(5, 2), labels=["x", "y"]) ... } >>> problem.add_points(additional_points)
- abstract move_discretisation_into_conditions()[source]#
Move the sampled points from the discretised domains into their corresponding conditions. This ensures that the conditions are evaluated on the correct set of points after discretisation.
- abstract property input_variables#
The input variables of the problem.
- abstract property output_variables#
The output variables of the problem.
- abstract property conditions#
The conditions associated with the problem.
- Returns:
The conditions associated with the problem.
- Return type:
- abstract property discretised_domains#
The dictionary containing the discretised domains of the problem. Each key corresponds to a domain defined in
domains, and each value is aLabelTensorcontaining the sampled points for that domain.- Returns:
The discretised domains.
- Return type: