src.spyice.update_physical_values#
- src.spyice.update_physical_values.H_function(_self, _temperature, _enthalpy_s1)[source]#
Calculates the value of H function.
- Parameters:
_self (float) – The value of self.
_temperature (float) – The temperature.
_enthalpy_s1 (float) – The enthalpy.
- Returns:
The calculated value of H function.
- Return type:
float
- src.spyice.update_physical_values.H_function_derivate(_x, _enthalpy_s1)[source]#
Calculates the derivative of the H function.
- Parameters:
_x (float) – The value of x.
_enthalpy_s1 (float) – The value of enthalpy_s1.
- Returns:
The derivative of the H function.
- Return type:
float
- src.spyice.update_physical_values.H_newton_iteration(_temperature, _enthalpy_s1)[source]#
Performs Newton iteration to find the root of the H_function.
- Parameters:
_temperature (float) – The temperature value.
_enthalpy_s1 (float) – The enthalpy value.
- Returns:
The root of the H_function.
- Return type:
float
- Raises:
None –
- src.spyice.update_physical_values.calculate_brine_velocity_darcyscheme(phi, phi_initial, dz, dt, nz, rho_i, rho_br, thickness_index_prev)[source]#
compute brine velocity (no gravity)
- Arguments——————————————————————
phi_initial initial liquid fraction, computed in previous time step [-] phi lastly updated liquid fraction in convergence scheme of the present time step [-] dz dt nz spatial discretization [m] time discretization [s] number of computational nodes
- Results—————
wkm1 brine velocity updated [ms-1]
- src.spyice.update_physical_values.calculate_brine_velocity_upwindscheme(phi, phi_initial, dz, dt, nz, rho_i, rho_br, thickness_index_prev)[source]#
compute brine velocity (no gravity) according to upwind scheme
- Arguments——————————————————————
phi_initial initial liquid fraction, computed in previous time step [-] phi lastly updated liquid fraction in convergence scheme of the present time step [-] dz dt nz spatial discretization [m] time discretization [s] number of computational nodes
- Results—————
wkm1 brine velocity updated [ms-1]
- src.spyice.update_physical_values.calculate_liquidus_temperature(_salinity, _liquid_relation='Normal')[source]#
- src.spyice.update_physical_values.calculate_melting_temperature_from_salinity(_salinity, _temperature_melt=270.8999285714286, _liquid_relation='Normal')[source]#
Calculates the melting temperature of seawater based on salinity.
- Parameters:
_salinity (numpy.ndarray) – Array of salinity values.
_temperature_melt (float, optional) – Melting temperature. Defaults to _temperature_melt.
_liquid_relation (str, optional) – Liquid relation type. Must be either “Normal” or “Frezchem”. Defaults to “Normal”.
- Returns:
Array of melting temperature values.
- Return type:
numpy.ndarray
- Raises:
TypeError – If _liquid_relation is not “Normal” or “Frezchem”.
- src.spyice.update_physical_values.phi_control_for_infinite_values(_phi)[source]#
Calculates the control values for infinite phi values.
- Parameters:
_phi (numpy.ndarray) – The input array of phi values.
- Returns:
The control values for the given phi values.
- Return type:
numpy.ndarray
- src.spyice.update_physical_values.phi_func(_enthalpy_k1, _enthalpy_s1)[source]#
Calculates the phi value based on the given enthalpy values.
- Parameters:
_enthalpy_k1 (float) – The enthalpy value for k1.
_enthalpy_s1 (float) – The enthalpy value for s1.
- Returns:
The calculated phi value.
- Return type:
float
- src.spyice.update_physical_values.update_algae_transport(preprocess_data_object, nutrient_cn_prev, phi_k, brine_velocity_prev, thickness_index_prev, nutrient_cn_initial, phi_initial, t_melt, source_term, buffo, stefan, voller, _nonconstant_physical_properties=False)[source]#
- Parameters:
preprocess_data_object (PreprocessData)
nutrient_cn_prev (np.ndarray)
phi_k (np.ndarray)
brine_velocity_prev (np.ndarray)
thickness_index_prev (float)
nutrient_cn_initial (np.ndarray)
phi_initial (np.ndarray)
t_melt (np.ndarray)
source_term (np.ndarray)
buffo (bool)
stefan (bool)
voller (bool)
_nonconstant_physical_properties (bool)
- src.spyice.update_physical_values.update_enthalpy(_temperature, _salinity, _liquid_fraction, _nz, _method='likebuffo')[source]#
Updates the enthalpy based on the given parameters.
- Parameters:
_temperature (float) – The temperature value.
_salinity (float) – The salinity value.
_liquid_fraction (float) – The liquid fraction value.
_nz (int) – The nz value.
_method (str, optional) – The method used for calculating enthalpy. Defaults to “likebuffo”.
- Returns:
The updated enthalpy value.
- Return type:
float
- Raises:
TypeError – If the given method is not available.
- src.spyice.update_physical_values.update_enthalpy_solid_state(_salinity, _nz, _liq_rel='Normal', _temperature_melt=270.8999285714286)[source]#
Updates the enthalpy in the solid state based on the given parameters. :param _salinity: The salinity value. :type _salinity: float :param _nz: The nz value. :type _nz: int :param _liq_rel: The liquid relation. Defaults to “Normal”. :type _liq_rel: str, optional :param _temperature_melt: The melting temperature. Defaults to _temperature_melt. :type _temperature_melt: float, optional
- Returns:
The updated enthalpy in the solid state.
- Return type:
float
- src.spyice.update_physical_values.update_liquid_fraction_buffo(_temperature, _salinity, _liquid_fraction, _enthalpy, _enthalpy_solid, _nz, _is_stefan=False, _method='likebuffo', _pt2_system=False)[source]#
Updates the liquid fraction based on temperature, salinity, enthalpy, and other parameters.
- Parameters:
_temperature (float) – The temperature value.
_salinity (float) – The salinity value.
_liquid_fraction (float) – The liquid fraction value.
_enthalpy (float) – The enthalpy value.
_enthalpy_solid (float) – The solid enthalpy value.
_nz (int) – The number of vertical grid points.
_is_stefan (bool, optional) – Whether to use Stefan condition. Defaults to False.
_method (str, optional) – The method to use. Defaults to “likebuffo”.
- Returns:
A tuple containing the updated liquid fraction values.
- Return type:
tuple
- Raises:
AssertionError – If the liquid fraction has a non-physical value.
- src.spyice.update_physical_values.update_liquid_fraction_mixture_with_enthalpy_equation(_temperature, _salinity, _liquid_fraction_previous, _enthalpy, _enthalpy_solid, under_relaxation_factor, _is_stefan=False)[source]#
Update the liquid fraction mixture using under-relaxation. :param _temperature: The current temperature. :type _temperature: float :param _salinity: The salinity of the mixture. :type _salinity: float :param _liquid_fraction_previous: The previous liquid fraction. :type _liquid_fraction_previous: float :param under_relaxation_factor: The under-relaxation factor to be applied. :type under_relaxation_factor: float :param _is_stefan: Flag to indicate if the Stefan condition should be applied. Defaults to False. :type _is_stefan: bool, optional
- Returns:
The updated liquid fraction mixture.
- Return type:
float
- src.spyice.update_physical_values.update_liquid_fraction_mixture_with_under_relaxation(_temperature, _salinity, _liquid_fraction_previous, under_relaxation_factor, _is_stefan=False)[source]#
Update the liquid fraction mixture using under-relaxation. :param _temperature: The current temperature. :type _temperature: float :param _salinity: The salinity of the mixture. :type _salinity: float :param _liquid_fraction_previous: The previous liquid fraction. :type _liquid_fraction_previous: float :param under_relaxation_factor: The under-relaxation factor to be applied. :type under_relaxation_factor: float :param _is_stefan: Flag to indicate if the Stefan condition should be applied. Defaults to False. :type _is_stefan: bool, optional
- Returns:
The updated liquid fraction mixture.
- Return type:
float
- src.spyice.update_physical_values.update_liquid_fraction_voller_continuous_thermal_properties(_temperature, _salinity, _phi, _enthalpy, _enthalpy_solid, under_relaxation_factor, temp_factor_3, _is_stefan=False, _method='likebuffo')[source]#
Updates the liquid fraction based on temperature, salinity, enthalpy, and other parameters.
- Parameters:
_temperature (float) – The temperature value.
_salinity (float) – The salinity value.
_liquid_fraction (float) – The liquid fraction value.
_enthalpy (float) – The enthalpy value.
_enthalpy_solid (float) – The solid enthalpy value.
_nz (int) – The number of vertical grid points.
_is_stefan (bool, optional) – Whether to use Stefan condition. Defaults to False.
_method (str, optional) – The method to use. Defaults to “likebuffo”.
- Returns:
A tuple containing the updated liquid fraction values.
- Return type:
tuple
- Raises:
AssertionError – If the liquid fraction has a non-physical value.
- src.spyice.update_physical_values.update_liquid_fraction_voller_under_relaxation(_temperature, _salinity, _temperature_initial, _liquid_fraction_previous, _temperature_previous, _salinity_previous, _nz, temp_factor_3, t_k_A_LHS_matrix, t_k_A_LHS_matrix_previous, under_relaxation_factor, _is_stefan=False, _pt2_system=False, _nonconstant_physical_properties=False)[source]#
Update the liquid fraction using the Voller under-relaxation method. :param - _temperature: The temperature value. :type - _temperature: float :param - _salinity: The salinity value. :type - _salinity: float :param - _liquid_fraction: The liquid fraction value. :type - _liquid_fraction: float :param - _nz: The number of vertical grid points. :type - _nz: int :param - temp_factor_3: The temperature factor. :type - temp_factor_3: float :param - under_relaxation_factor: The under-relaxation factor. :type - under_relaxation_factor: float :param - _is_stefan: Whether to use Stefan condition. Defaults to False. :type - _is_stefan: bool, optional
- Returns:
The updated liquid fraction values.
- Return type:
numpy.ndarray
- Raises:
- AssertionError – If the liquid fraction has a non-physical value
- src.spyice.update_physical_values.update_state_variables(preprocess_data_object, t_prev, s_prev, brine_velocity_prev, nutrient_cn_prev, phi_prev, thickness_index_prev, buffo, stefan, voller, t_initial, s_initial, nutrient_cn_initial, phi_initial, t_k_melt, t_k_A_LHS_matrix_prev, temp_factor_3, source_term_temperature, source_term_salinity, x_wind_temperature, x_wind_salinity, _is_salinity_equation, _is_algae_equation, _is_diffusiononly_equation=False)[source]#
Update the state variables Temperature, Salinity, Liquid Fraction, Enthalpy and Enthalpy of solid based on the given parameters.
- Parameters:
preprocess_data_object (PreprocessData) – The preprocess data object.
t_km1 (numpy.ndarray) – The previous temperature values.
s_km1 (numpy.ndarray) – The previous salinity values.
nutrient_cn (numpy.ndarray) – The previous nutrient concentration values
phi_km1 (numpy.ndarray) – The previous liquid fraction values.
buffo (bool) – The buffo flag.
stefan (bool) – The stefan flag.
t_initial (numpy.ndarray) – The initial temperature values.
s_initial (numpy.ndarray) – The initial salinity values.
nutrient_cn_initial (numpy.ndarray) – The initial nutrient concentration values
phi_initial (numpy.ndarray) – The initial liquid fraction values.
source_term (numpy.ndarray) – The source term values like radiation ocean flux, algae, etc.
- Methods called:
- Updates the state variables based on the given parameters.
update_enthalpy: Update the enthalpy of the system with previous temperature, salinity, liquid fraction.
update_enthalpy_solid_state: Update the enthalpy of the solid state with previous salinity using the liquidus relation.
update_liquid_fraction: Update the liquid fraction of the system with previous temperature, salinity, enthalpy, solid enthalpy.
update_temperature_and_salinity: Update the temperature and salinity of the system with updated liquid fraction and previous temperature, salinity, initial temperature, initial salinity, initial liquid fraction, source term, buffo, stefan.
update_algae_transport: Update the nutrient concentration of the system
- Returns:
- A tuple containing the following updated values:
h_k (numpy.ndarray): The updated enthalpy values.
h_solid (numpy.ndarray): The updated solid enthalpy values.
phi_k (numpy.ndarray): The updated liquid fraction values.
t_k (numpy.ndarray): The updated temperature values.
s_k (numpy.ndarray): The updated salinity values.
nutrient_cn (numpy.ndarray): The updated nutrient values
- Return type:
tuple
- Parameters:
preprocess_data_object (PreprocessData)
- src.spyice.update_physical_values.update_temperature_and_salinity(preprocess_data_object, t_prev, s_prev, phi_k, brine_velocity_prev, thickness_index_prev, t_initial, s_initial, phi_initial, t_melt, source_term_temperature, source_term_salinity, x_wind_temperature, x_wind_salinity, buffo, stefan, voller, _is_salinity_equation, _nonconstant_physical_properties=False, t_k_A_LHS_matrix_prev=None)[source]#
Update the temperature and salinity based on the given parameters.
- Parameters:
preprocess_data_object (PreprocessData) – The preprocess data object.
t_prev (numpy.ndarray) – The previous temperature values.
s_prev (numpy.ndarray) – The previous salinity values.
phi_k (numpy.ndarray) – The liquid fraction values.
t_initial (numpy.ndarray) – The initial temperature values.
s_initial (numpy.ndarray) – The initial salinity values.
phi_initial (numpy.ndarray) – The initial liquid fraction values.
source_term (numpy.ndarray) – The source term values.
buffo (bool) – The buffo flag.
stefan (bool) – The stefan flag.
_is_salinity_equation (bool, optional) – Whether to consider the salinity equation. Defaults to False.
brine_velocity_prev (np.ndarray)
thickness_index_prev (float)
t_melt (np.ndarray)
source_term_temperature (np.ndarray)
source_term_salinity (np.ndarray)
x_wind_temperature (np.ndarray)
x_wind_salinity (np.ndarray)
voller (bool)
_nonconstant_physical_properties (bool)
t_k_A_LHS_matrix_prev (np.ndarray)
- Returns:
A tuple containing the updated temperature and salinity values. a_p: The main diagonal of the matrix A for the Voller scheme liquid fraction update
- Return type:
tuple