1. Write a Python script which performs a non-linear regression on the data "ammonia.txtDownload ammonia.txt" to fit the Antoine's equation. You can use the script from Ex. 15.5 or the...

1 answer below »


1. Write a Python script which performs a non-linear regression on the data "


ammonia.txt


Download ammonia.txt



" to fit the Antoine's equation. You can use the script from Ex. 15.5 or the scipy.optimize.curve_fit function (or other alternatives, as long as they work).


- Your script should include plotting the data: experimental vs model


- Find the Antoine equation parameters in the literature and compare with yours. Include the plots and the parameters in a separate file.










https://www.youtube.com/watch?v=_lePLScygK0




I need to use Non Linear Regression like in the video but for my text file called ammonia. I started and i am getting errors I do not know how to solve.






import numpy as np

from plotly.subplots import make_subplots





data= np.loadtxt("ammonia.txt", skiprows=5)

print(data)

T= data[:,0]

logP= np.log10(data[:,1])





fig = make_subplots(rows=1, cols=1)

fig.add_scatter(x=T, y=logP, mode='markers', name='Data')

fig.update_layout(height=600, width=800)





X= np.c_[T, -logP, np.ones_like(T)]

A,C,D = np.linalg.inv(X,T@X)@X.T@(T*logP)

B= (A*C) - D

Tplot= np.linspace(min(T), max(T), 100)

fig.add_scatter(x=Tplot, y= A - (B/(Tplot+C)), mode= 'lines', name='Linear Regression')
















199.2626.1880.0040.01 203.1148.2610.0040.01 206.58710.6080.0040.01 210.81114.1810.0040.01 214.4218.0170.0040.01 218.35423.1260.0040.01 224.24632.980.0040.01 229.20543.7250.0040.01 234.8459.2480.0040.01 241.58583.5350.0040.01
Answered Same DayNov 16, 2022

Answer To: 1. Write a Python script which performs a non-linear regression on the data "ammonia.txtDownload...

Baljit answered on Nov 17 2022
59 Votes
In [1]:
In [2]:
In [3]:
import numpy as np
from plotly.subplots import make_subplots
from scipy
.optimize import minimize
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
data= np.loadtxt("ammonia.txt")
T=data[:,0]
logP= np.log10(data[:,1])
def funct(T,a,b,c):
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here