thermohub/test code/Ternary Diagram Practice.py
2026-01-07 15:32:30 -05:00

43 lines
997 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 29 12:12:56 2025
Plots the water, acetone and n-octane ternary diagram at 25 °C as calculated
by Aspen Plus.
@author: lobo
"""
import numpy as np
import matplotlib.pyplot as plt
import mpltern
data_set = np.loadtxt("WaterAcetoneOctaneEquil.csv", delimiter = ',', skiprows=2)
water = data_set[:,1]
acetone = data_set[:,2]
octane = data_set[:,3]
ax = plt.subplot(projection='ternary')
ax.plot(acetone, octane, water)
#Tie Lines
ax.plot([0,0],[0.9989768, 2.43E-06], [0.00102325, 0.9999976], 'b')
ax.plot([0.1248013,0.1403329],[0.8706273,0.000389155],[0.00457142,0.8592779], 'r')
ax.plot([0.2102607,0.3371009],[0.7798967,0.00720065],[0.00984261,0.6556985], 'k')
ax.plot([0.2552231,0.5722035],[0.731291,0.055398],[0.0134858,0.3723985], 'g')
ax.plot([0.4018703,0.6527512],[0.5729588,0.2466414],[0.0251709,0.1006074], 'c')
ax.grid()
ax.set_tlabel("Acetone")
ax.set_llabel("n-Octane")
ax.set_rlabel("Water")
plt.show()