434,778 Members | 1,318 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,778 IT Pros & Developers. It's quick & easy.

Python program to calculate an expression (equation) from the values of second column

 P: 4 I have values as: 0.263 0 0.265 0 0.267 0 0.269 0.0001 0.271 0.0003 0.273 0.0006 0.275 0.0011 0.277 0.0021 0.279 0.0029 0.281 0.0046 0.283 0.0072 0.285 0.0113 And i want to calculate the expression ie., PMF(W_r)= k_b T ln g(r). Where the g(r) are the values of the second column. Here is the code that i have tried: Expand|Select|Wrap|Line Numbers import numpy as np #import panda as pd import scipy.constants as sc #from astropy import constants as const import matplotlib.pyplot as plt import math A=open('rdf_CaOw.dat','r') B=open('pmf.dat','w') for column in A:     c=column.strip().split()     B.write(column[6:11]+'\n') B.close() A.close()   C=open('pmf.dat', 'r') D=open('pmf1.dat','w') for line in C:     W = (- float(sc.Boltzmann * 298 * float (math.log (C))))     print (W)   1) Any suggestions on this. 2) Can i directly take the second column and insert/put in the equation to calculate..?? How can i do this? Since here i am writing the second column to one output file and from that output file again i am putting the equation. Any suggestions are highly appreciated. Thank you. May 28 '18 #1 