
# Load the COSMO species
database = CosmoRSSpeciesDatabase()
water = database.exportSpecies('water')
water.setMeltingPoint(273.15 * Kelvin)
water.setEnthalpyOfFusion(6 * kiloJoulePerMol)
specific_heat_capacity_change = (4.187 - 2.108) * Joule / (gram*Kelvin)
specific_heat_capacity_change *= water.molarMass()
water.setSpecificHeatCapacityChange(specific_heat_capacity_change)

# Create the solid at 10K below the melting point.
solid = CosmoRealSolid(
    263*Kelvin,
    parameters=CosmoRSParameters(),
)

# Calculate Gibbs free energy of fusion of ice.
dG_fus = solid.freeEnergyOfFusion(water).convertTo(kiloJoulePerMol)
nlprint(f'The free energy of fusion of ice is {dG_fus}')

# Calculate chemical potential of ice.
chemical_potential = solid.chemicalPotential(water).convertTo(kiloJoulePerMol)
nlprint(f'The chemical potential of ice is {chemical_potential}')
