Consider a heat transfer model where a heat flux of 1 W/m2 flows in through one boundary of a square 2D region. All other boundaries are kept at a fixed temperature of 293.15 K. The material is copper. This example verifies that the flux is conserved exactly using a Lagrange multiplier for computing the total flux over the boundaries with a fixed temperature.
The Heat Transfer in Solids node defines the material properties to be those from the material (copper) and does not need to be changed, but the default boundary condition is thermal insulation. Instead, add a heat flux to the bottom boundary and a fixed temperature on the other three boundaries.
To display the weak constraint option to add the Lagrange multipliers, click the Show button (

) and select
Advanced Physics Options. In the
Model Builder click the
Temperature node. In the
Settings window, keep the default value for the temperature, 293.15 K. Click to expand the
Constraint Settings section and select the
Use weak constraints check box. This adds a Lagrange multiplier for the heat flux as an extra variable to compute.
On the Home toolbar click
Compute 
. The resulting plot shows the temperature distribution in the domain.
The total normal heat flux across these boundaries appears in the Table under
Normal total heat flux (W/m) and is exactly equal to the influx of 1 W/m (the normal flux is by convention positive in the direction of the normal).
If you were to clear the Compute boundary fluxes check box in the
Discretization section (click the
Show button

and select
Discretization) for the
Heat Transfer in Solids node, and then re-solve the model, the same flux variable is not as accurate and has a value of about 0.986 W/m. That value approaches 1 if you refine the mesh.
The total heat flux across these boundaries appears in the Table under
Lagrange multiplier for temperature and is
−1, exactly equal to the influx (but with opposite sign) without the need for a computationally expensive extremely fine mesh. This makes this method useful for physics where built-in accurate flux variables are not available.