-
Notifications
You must be signed in to change notification settings - Fork 63
[FXC-1512]: Add natural convection BC #2696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 5 comments
h = (self.fluid_k / self.plate_L) * h_factor_linear | ||
h_nonlinear = (self.fluid_k / self.plate_L) * h_factor_non_linear | ||
exponent = 1 + 1/6 | ||
return h, h_nonlinear, exponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Method returns computed values but they're not used anywhere. Consider if this method should modify instance state or be called differently.
bbe0d31
to
f737cae
Compare
This comment was marked as outdated.
This comment was marked as outdated.
f737cae
to
bbe0d31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @damiano-flex ! This is looking very good from the get-go!
Apart from the minor comments that I left we're missing unit tests. I think once you add these we'll be good to go
Specification for natural convection from a vertical plate. | ||
|
||
This class calculates the heat transfer coefficient (h) based on fluid | ||
properties and an expected temperature difference, then provides these | ||
values as 'base' and 'exponent' for a generalized heat flux equation | ||
q = base * (T_surf - T_fluid)^exponent. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add in the docstring that one can define the constants in SI with from_si_units
and maybe add a couple of examples like with the rest of the BC classes: one using the standard constructor and another one with the from_si_units
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can help readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks all makes sense, but I would add all required fluid parameters into FluidMedium
(probably using more explicit names like viscosity
, expansivity
, etc, to be consistent with SolidMedium
) and make this new convection bc automatically get those parameters from fluids it touches. It means that we also need to add a validator that checks that these pararmeters are defined for fluid mediums in our simulations if natural convection is used.
Additionally, I would also move _compute_parameters
to the backend
fluid_k: pd.NonNegativeFloat = pd.Field( | ||
title="Fluid Thermal Conductivity", | ||
description="Thermal conductivity (k) of the fluid.", | ||
units=THERMAL_CONDUCTIVITY, | ||
) | ||
fluid_mu: pd.NonNegativeFloat = pd.Field( | ||
title="Fluid Dynamic Viscosity", | ||
description="Dynamic viscosity (μ) of the fluid.", | ||
units=DYNAMIC_VISCOSITY, | ||
) | ||
fluid_Cp: pd.NonNegativeFloat = pd.Field( | ||
title="Fluid Specific Heat", | ||
description="Specific heat of the fluid at constant pressure.", | ||
units=SPECIFIC_HEAT, | ||
) | ||
fluid_rho: pd.NonNegativeFloat = pd.Field( | ||
title="Fluid Density", | ||
description="Density (ρ) of the fluid.", | ||
units=DENSITY, | ||
) | ||
fluid_beta: pd.NonNegativeFloat = pd.Field( | ||
title="Fluid Thermal Expansivity", | ||
description="Thermal expansion coefficient (β) of the fluid.", | ||
units=THERMAL_EXPANSIVITY, | ||
) | ||
plate_L: pd.NonNegativeFloat = pd.Field( | ||
title="Plate Characteristic Length", | ||
description="Characteristic length (L), defined as the height of the vertical plate.", | ||
units=MICROMETER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should all fluid properties be pulled automatically from medium properties that touches that boundary? Sounds like we should expand heat_spec with these additional properties. For other parameters I would use more explicit names: plate_L
-> plate_length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some thoughts before answer this comment. Ultimately, I agree, pulling medium properties seems indeed an appropriate choice. If one wants to add 4 natural convection walls the code would look like much more cleaner.
Some more out-loud thinking: Probably still need to have a medium parameter in the natural convection if one wants to define it on a simulation boundary, something like
Might also make sense to restrict automatic What do you think? |
Greptile Summary
This PR introduces a new
NaturalConvectionVerticalSpec
class to enhance thermal boundary condition modeling in the Tidy3D framework. The class enables automatic calculation of heat transfer coefficients for natural convection from vertical plates based on fluid properties rather than requiring manual coefficient specification.The implementation follows standard heat transfer engineering practices by using Rayleigh number calculations and appropriate Nusselt number correlations to determine heat transfer coefficients. It supports both laminar and turbulent flow regimes based on critical Rayleigh number thresholds. The class accepts comprehensive fluid property inputs including thermal conductivity, viscosity, density, specific heat, and thermal expansion coefficient.
The integration is achieved by extending the existing
ConvectionBC.transfer_coeff
field to accept either a simple float (existing behavior) or the newNaturalConvectionVerticalSpec
object, maintaining backward compatibility. The class is properly exported through the main package interface and integrated into the TCAD types system, following established patterns in the codebase for thermal boundary conditions.Confidence score: 2/5
_compute_parameters
method returns unused values suggesting incomplete integrationtidy3d/components/tcad/boundary/heat.py
needs immediate attention for unit consistency, parameter validation, and completion of the computation logic