API Reference
This page lists the main classes and functions available in deepflow.
Domain
The domain module handles the creation and management of the computational domain, including geometry, boundary conditions, and sampling.
domain
Creates a ProblemDomain instance from a list of Area or Bound objects.
Arguments:
- *geometries: Can be single Area/Bound objects or lists of them.
ProblemDomain
The main class managing the physics problem.
Methods:
- sampling_uniform(bound_sampling_res, area_sampling_res): Samples points uniformly.
- sampling_random(bound_sampling_res, area_sampling_res): Samples points randomly.
- sampling_lhs(bound_sampling_res, area_sampling_res): Samples points using Latin Hypercube Sampling.
- sampling_R3(bound_sampling_res, area_sampling_res): Samples points using R3 refinement.
- show_setup(): Plots the domain geometry and boundary conditions.
- show_coordinates(display_physics=False): Plots the sampled collocation points.
calc_loss_simple
Returns a loss function that calculates the weighted sum of boundary and PDE losses for the given domain.
Geometry
The deepflow.geometry module provides helper functions to create 1D and 2D geometries.
rectangle
Creates a rectangular area.
circle
Creates a circular area.
Bound
Represents a boundary (e.g., line segment).
Area
Represents a 2D area. Supports subtraction (e.g., rect - circle).
PDE
The deepflow.pde module contains standard Partial Differential Equations.
NavierStokes
2D Incompressible Navier-Stokes equations.
BurgersEquation1D
1D Burgers' equation.
HeatEquation
2D Heat equation.
Neural Network
PINN
Physics-Informed Neural Network model.
Methods:
- train_adam(calc_loss, learning_rate, epochs, ...): Train using Adam optimizer.
- train_lbfgs(calc_loss, epochs, ...): Train using L-BFGS optimizer.
- save_as_pickle(path): Save model.
- load_from_pickle(path): Load model.
Evaluation
Evaluator (Visualizer)
Returned by domain.area_list[i].evaluate(model).
Methods:
- sampling_area(res_list): Sample points for visualization.
- plot(key): Plot a variable.
- plot_color(key): Plot a variable as a color map.
- plot_streamline(u, v): Plot streamlines.
- plot_loss_curve(): Plot loss history.
- plot_animate(...): Create animation (for transient problems).