<jupyter_start><jupyter_text>Electrostatic functions  - Electrostatic force between the charges $q_1$ & $q_2$ separated by distance $r$ is given by $F=\frac{Kq_1q_2}{r^2}$<jupyter_code>def force(q1,q2,r): 
    f=k*q1/r
    return f
k=9*10**9
force(1,1,1) #when q1=1C, q2=1C and r=1m the force between q1 and q2 is:<jupyter_output><empty_output><jupyter_text>- Electrostatic Potential of charge $q_1$ at distance $r$ $V=\frac{Kq_1}{r}$<jupyter_code>def potential(q1,r):
    v=k*q1/r
    return v
k=9*10**9
potential(1,1) # when q1-1c and r=1m the potential is:<jupyter_output><empty_output><jupyter_text>- Electric Field Intensity of charge $q_1$ at distance $r$ is: $V=\frac{Kq_1}{r^2}$<jupyter_code>def intensity(q1,r):
    I=k*q1/r**2
    return I
k=9*10**9
intensity(1,1) # when charge q1 = 1C and distance r = 1m, the intensity is:<jupyter_output><empty_output><jupyter_text>Now, let us make a class of three functions "Electrostatic":<jupyter_code>class Electrostatic():
    def __init__(self,value_k,info,info1,info2):
        self.k=value_k
        self.info=info
        self.info1=info1
        self.info2=info2
    def force(self,q1,q2,r):
        f=self.k*q1*q2/r**2
        #print(self.give)
        return f
    def potential(self,q1,r):
        v=self.k*q1/r
        #print(self.info1)
        return v
    def intensity(self,q1,r):
        I=self.k*q1/r**2
        #print(self.info2)
        return I
E1=Electrostatic(value_k=9*10**9,info='This is coulomb force',info1='This is coulomb potential',info2='This is intensity' )
#E.force(1,1,1),E.potential(1,1),E.intensity(1,1)
q1=3.2*10**-16 #let us fix the charge q1
q2=3.2*10**-10 #fix another charge q2 
R=[]  #empty list of distance
F=[]  #empty list of force
V=[]  #empty list of potential
E=[]  #empty list of intensity
for r in range(1,10000): #taking the calue of distance from 1 to 1000
    ff=E1.force(q1,q2,r) 
    vv=E1.potential(q1,r)
    ee=E1.intensity(q1,r)
    R.append(r)
    F.append(ff)
    V.append(vv)
    E.append(ee)
#print(R,F,V,E)<jupyter_output><empty_output><jupyter_text>- Create a dictionary of above created list<jupyter_code>data={} #create an empty list
data.update({"Distance":R, "Force":F, "Potential":V, "Intensity":E}) #update above information with Rename
#print(data)<jupyter_output><empty_output><jupyter_text>- Convert dictionary to DataFrame<jupyter_code>import pandas as pd
DF=pd.DataFrame(data)  
#print(DF)<jupyter_output><empty_output><jupyter_text>- Save DataFrame in csv (comma separated variable) Excel file<jupyter_code>DF.to_csv('Electrostatic_variable.csv')<jupyter_output><empty_output><jupyter_text>- Read and Open the csv file from computer by jupyter notebook<jupyter_code>df=pd.read_csv('Electrostatic_variable.csv')
df.head() #head mean title eg; distance, Force, Potential, ...<jupyter_output><empty_output><jupyter_text>- Make a plot between variables in  columns in csv file<jupyter_code>import matplotlib.pyplot as plt
%matplotlib inline
#plt.figure(figsize=(10,10))
plt.plot(df.Distance,df.Force,'o',color='r',label='force',lw=1) #lw= line width
plt.plot(df.Distance,df.Potential,'.',color='g',label='potential',lw=1)
plt.plot(df.Distance,df.Intensity,'-.',color='b',label='intensity',lw=1)
plt.xlabel("Distance(m)")
plt.ylabel("Force(N), Potential(V), Intensity(N/m^2)")
plt.grid(True)<jupyter_output><empty_output><jupyter_text>This graph doesnot gives better vizualization for the variation of electrostatic functions with distance. Also, there is no clear difference for variation of force, potential and intensity with distance. For the better vizualization we need semilog or loglog plot. Log - log and semi - log plot are done if the range of variation of data is wide.  Semi - Log PlotIn semi - log plot, variable in one axis is in mog scale and variable in other axis is left as it is. In the following semi - log plot, the variable in y axis (i.e., force, potential and intensity) are plotted in log scale and distance is left as it is. Which can be seen in the plot below;<jupyter_code>plt.semilogy(df.Distance,df.Force,label='force')
plt.semilogy(df.Distance,df.Potential,label='potential')
plt.semilogy(df.Distance,df.Intensity,label='intensity')
plt.xlabel("Distance(m)")
plt.ylabel("log(F), log(V), log(E)")
plt.legend()
plt.grid(True)<jupyter_output><empty_output><jupyter_text>Log - Log PlotIn log - log plot, variable in both axis are in log scale. It helps for better visualization in every point of graph, more than semi - log plot. Which can be seen in the plot below;<jupyter_code>plt.loglog(df.Distance,df.Force,label='force')
plt.loglog(df.Distance,df.Potential,label='potential')
plt.loglog(df.Distance,df.Intensity,label='intensity')
plt.xlabel("log(R)",fontsize=16)
plt.ylabel("log(F), log(V), log(E)",fontsize=16)
plt.legend(loc='center',fontsize=16)
plt.grid(True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14044132810888843, 'fraction_numerical': 0.02680965147453083, 'mean_word_length': 5.483957219251337, 'pattern_counts': {'":': 5, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '389312', 'license': 'MIT', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1779, 'n_words': 435, 'path': 'Electrostatic_aug2.ipynb', 'repo_name': 'joshidot/Functions', 'size': '4849'}