<jupyter_start><jupyter_text><jupyter_code>#@title Calculation of freezing point in LNG
#@markdown Demonstration of calculations of freezing points in LNG processing
%%capture
!pip install neqsim
import neqsim
from neqsim.thermo.thermoTools import *
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import math
%matplotlib inline
#@title Introduction to freezing in LNG
#@markdown This video gives an intriduction to freezing of CO2 in LNG processing
from IPython.display import YouTubeVideo
YouTubeVideo('RvoeLXCaSig', width=600, height=400)<jupyter_output><empty_output><jupyter_text>Calculation off freezing point in LNGIn the following example we use PR/SRK to claculate the freezing point in an LNG mixture<jupyter_code>camponentName = "methane" #@param ["methane", "ethane", "CO2"]
eos = "srk" #@param ["srk", "pr"]
fluid1 = fluid(eos) #create a fluid using the SRK-EoS
fluid1.addComponent(camponentName, 1.0) #adding 1 mole methane to the fluid

TTrip = fluid1.getPhase(0).getComponent(camponentName).getTriplePointTemperature()
PTrip = fluid1.getPhase(0).getComponent(camponentName).getTriplePointPressure()
Tcritical = fluid1.getPhase(0).getComponent(camponentName).getTC()
Pcritical = fluid1.getPhase(0).getComponent(camponentName).getPC()

fluid1.setTemperature(TTrip)
fluid1.setPressure(PTrip)
print('triple point temperature ', TTrip, "[K] and pressure ", PTrip, "[bara]")
print('critical temperature ', Tcritical, "[K] and pressure ", Pcritical, "[bara]")

def bubleP(pressure):
    fluid1.setPressure(pressure)
    bubt(fluid1)
    return fluid1.getTemperature('C')

pressure = np.arange(PTrip, Pcritical-15.0, 1.0)
temperature = [bubleP(P) for P in pressure]

plt.plot(temperature, pressure);
plt.yscale('log')
plt.xlabel('Temperature [C]');
plt.ylabel('Pressure [bara]');<jupyter_output>triple point temperature  90.69 [K] and pressure  0.116656057 [bara]
critical temperature  190.55999999999997 [K] and pressure  45.99 [bara]<jupyter_text>A TPflash with mercuryCalculate the composition of a fluid including mercury<jupyter_code>componentName = "methane" #@param ["methane", "ethane", "propane", "CO2", "nitrogen"]
temperature = 55.0   #@param {type:"number"}
pressure = 10.0 #@param {type:"number"}


# Creating a fluid in neqsim
fluid1 = fluid('srk') #create a fluid using the SRK-EoS
fluid1.addComponent(componentName, 1.0) 
fluid1.addComponent('mercury', 1.0)
fluid1.setTemperature(temperature)
fluid1.setPressure(pressure)
fluid1.setMultiPhaseCheck(True)

fluid1.setTemperature(temperature+273.15)
fluid1.setPressure(pressure)
TPflash(fluid1)
fluid1.initPhysicalProperties()
print('mercury in ', fluid1.getPhase(0).getPhaseTypeName(), ' ',fluid1.getPhase(0).getComponent(0).getComponentName(), ' ', fluid1.getPhase(0).getComponent('mercury').getx())<jupyter_output>mercury in  gas   methane   7.573992808703628e-07
{'fraction_non_alphanumeric': 0.12281315605318405, 'fraction_numerical': 0.040937718684394685, 'mean_word_length': 7.122159090909091, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '367443', 'license': 'Apache-2.0', 'n_tokens_mistral': 1067, 'n_tokens_neox': 956, 'n_words': 237, 'path': 'notebooks/thermodynamics/freezing_in_LNG.ipynb', 'repo_name': 'EvenSol/testneqsim', 'size': '2858'}