Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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.txtDownload 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')



Answered Same Day Nov 16, 2022

Solution

Baljit answered on Nov 17 2022
45 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