MecSimCalc
ExploreSearchCreateDocsCommunityBlogPricing
    Apps

    Starred
    Go to app
    App Docs

Here is the code used:


import numpy as np
GaussTable = [[[0], [2]], [[-1/np.sqrt(3), 1/np.sqrt(3)], [11]], [[-np.sqrt(3/5), 0, np.sqrt(3/5)], [5/98/95/9]], [[-0.861136, -0.3399810.3399810.861136], [0.3478550.6521450.6521450.347855]], [[-0.90618, -0.53846900.5384690.90618], [0.2369270.4786290.5688890.4786290.236927]], [[-0.93247, -0.661209, -0.2386190.2386190.6612090.93247], [0.1713240.3607620.4679140.4679140.360762,  0.171324]]]



def f(r,th):
    return r**2*np.cos(th)
def IGAL(f, n1, r1, r2, n2,th1,th2):
  n1 = int(n1)
  n2=int(n2)
  return sum([sum([(r2 - r1)/2*GaussTable[n1 - 1][1][i]*(th2 - th1)/2*GaussTable[n2 - 1][1][j]*f((r2 - r1)/2*(GaussTable[n1 - 1][0][i] + 1) + r1,(th2 - th1)/2*(GaussTable[n2 - 1][0][j] + 1) + th1) for i in range(n1)]) for j in range(n2)])



def main(inputs):
    n1=inputs['n_1']
    n2=inputs['n_2']
    r1=inputs['r_1']
    r2=inputs['r_2']
    th1=inputs['th_1']*np.pi
    th2=inputs['th_2']*np.pi
    n1=2
    n2=2
    s=IGAL(f,n1,r1,r2,n2,th1,th2)
    #print(s)
    return {"Sol":s,"n1":n1,"n2":n2,"r1":r1,"r2":r2,"th1":inputs['th_1'],"th2":inputs['th_2']}

Similar apps:
Engineering
Gauss Integration

Copyright © MecSimCalc 2025
Terms | Privacy