Ejemplo n.º 1
0
nodeH = data[2]
pList = data[3]
U_con_order = data[4]

# Call Choleski
print "#Call Choleski"
U_f = Choleski(A, b)

# put results in appropriate nodes in nodeH
for i in range(1, U_f.rows + 1):
    nodeH[U_con_order[i - 1]].voltage = U_f.get(i, 1)

# nodeH at this point has all the proper voltages

# for each triangle, see if the point we're after is inside
MeshStructure.buildStructs(filename + ".msh")  # we need triangleL
triangleL = MeshStructure.triangleL
for i in range(0, len(triangleL)):
    n1 = triangleL[i].node1
    n2 = triangleL[i].node2
    n3 = triangleL[i].node3
    alpha = getAlpha(n1.x, n1.y, n2.x, n2.y, n3.x, n3.y, 0.05, 0.05)
    beta = getBeta(n1.x, n1.y, n2.x, n2.y, n3.x, n3.y, 0.05, 0.05)
    gamma = 1 - alpha - beta

    if (alpha >= 0 and alpha <= 1) and (beta >= 0 and beta <= 1) and (gamma >= 0 and gamma <= 1):
        potential = (
            nodeH[n1.number].voltage * alpha + nodeH[n2.number].voltage * beta + nodeH[n3.number].voltage * gamma
        )
        f = open("Chol_results.csv", "a")
        f.write(str(U_f.rows) + "," + str(potential) + "\n")
Ejemplo n.º 2
0
		
	f.write("node,x,y,potential,predefined\n")
	for i in range(1,len(nodeH)+1):
		f.write(str(nodeH[i].number)+","+str(nodeH[i].x)+","+str(nodeH[i].y)+","+str(nodeH[i].voltage))
		if ( nodeH[i].number in pList):
			f.write(",y\n")
		else:
			f.write("\n")
		
	f.close()
				
#t1=MeshStructure.Triangle(MeshStructure.Node(1,0,0.02,0.0),MeshStructure.Node(2,0,0,0.0),MeshStructure.Node(3,0.02,0,0.0))
#t2=MeshStructure.Triangle(MeshStructure.Node(4,0.02,0.02,0.0),MeshStructure.Node(5,0,0.02,0.0),MeshStructure.Node(6,0.02,0,0.0))
#buildGlobal_S([t1,t2])
#MeshStructure.buildStructs('squareCoax3_D.msh')
import sys
if (len(sys.argv) > 1):
	filename = sys.argv[1]
	MeshStructure.buildStructs(filename+".msh")
	buildGlobal_S(MeshStructure.nodeH, MeshStructure.triangleL, MeshStructure.pList)
	reduced()
	U_f = Choleski(S_ff,S_fp.multiply(U_p))
	printResults(MeshStructure.nodeH,MeshStructure.pList,filename+".csv")
else:
	print "please specify a filename without extension"