Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168693
Image: ubuntu2004
import numpy as np Nx=4 Ny=4 nsom=Nx*Ny x=np.linspace(0,1,Nx) y=np.linspace(0,1,Ny) nel= 2*(Nx-1)*(Ny-1) coord=np.empty((nsom,2),dtype='float') som=np.empty((nel,3),dtype='int') for i in range(Nx): for j in range(Ny): coord[i+j*Nx,0]=x[i] coord[i+j*Nx,1]=y[j] coord
array([[ 0. , 0. ], [ 0.33333333, 0. ], [ 0.66666667, 0. ], [ 1. , 0. ], [ 0. , 0.33333333], [ 0.33333333, 0.33333333], [ 0.66666667, 0.33333333], [ 1. , 0.33333333], [ 0. , 0.66666667], [ 0.33333333, 0.66666667], [ 0.66666667, 0.66666667], [ 1. , 0.66666667], [ 0. , 1. ], [ 0.33333333, 1. ], [ 0.66666667, 1. ], [ 1. , 1. ]])
ct=0 for j in range(Ny-1): for i in range(Nx-1): som[ct,0]=i+j*Nx som[ct,1]=i+1+j*Nx som[ct,2]=i+(j+1)*Nx ct+=1 som[ct,0]=i+1+j*Nx som[ct,1]=i+1+(j+1)*Nx som[ct,2]=i+(j+1)*Nx ct+=1 som
array([[ 0, 1, 4], [ 1, 5, 4], [ 1, 2, 5], [ 2, 6, 5], [ 2, 3, 6], [ 3, 7, 6], [ 4, 5, 8], [ 5, 9, 8], [ 5, 6, 9], [ 6, 10, 9], [ 6, 7, 10], [ 7, 11, 10], [ 8, 9, 12], [ 9, 13, 12], [ 9, 10, 13], [10, 14, 13], [10, 11, 14], [11, 15, 14]])
lar=[] for i in range(nel): ar01=(min(som[i,0],som[i,1]),max(som[i,0],som[i,1]))) ar12=(min(som[i,1],som[i,2]),max(som[i,1],som[i,2]))) ar20=(min(som[i,2],som[i,0]),max(som[i,2],som[i,0]))) try: lar_index(ar01) except Value Error: lar.append(ar01)
Traceback (most recent call last): lar_index(ar01) File "", line 1, in <module> File "/tmp/tmpGjQWYO/___code___.py", line 5 ar01=(min(som[i,_sage_const_0 ],som[i,_sage_const_1 ]),max(som[i,_sage_const_0 ],som[i,_sage_const_1 ]))) ^ SyntaxError: invalid syntax