Update test_battery.py
This commit is contained in:
parent
16316bb3da
commit
36771c7d0d
@ -3,14 +3,14 @@ import itertools
|
||||
load('aplK.py')
|
||||
load("minimalModel_parallel.py")
|
||||
|
||||
"""
|
||||
S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
A = AlgebraAplK(S)
|
||||
smodel = load("sullivan_model_K3_deg3.sobj")
|
||||
smorphism = load("model_morphism_K3_deg3.sobj")
|
||||
"""
|
||||
|
||||
#S = simplicial_complexes.K3Surface()
|
||||
#S.set_immutable()
|
||||
#cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
#A = AlgebraAplK(S)
|
||||
#smodel = load("sullivan_model_K3_deg3.sobj")
|
||||
#smorphism = load("model_morphism_K3_deg3.sobj")
|
||||
|
||||
######### RUN MINIMAL MODEL ALGORITHM
|
||||
"""
|
||||
[sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=12000, max_dim=3)
|
||||
@ -108,44 +108,50 @@ for f in range(n+1):
|
||||
#print(p.integral() == dq.integral(), flush=True)
|
||||
"""
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APL(K)
|
||||
"""
|
||||
def zip_with_constants(a, l):
|
||||
return [(a, i) for i in l]
|
||||
|
||||
def zip_with_constants(a,s,c, l):
|
||||
return [(a,s,c, i) for i in l]
|
||||
|
||||
@parallel(ncpus=Integer(24))
|
||||
def check(A,S):
|
||||
"""
|
||||
|
||||
#S = simplicial_complexes.Sphere(6)
|
||||
S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
A = AlgebraAplK(S)
|
||||
for dim in range(4):
|
||||
for i in range(1):
|
||||
v = random_vector(QQ, len(S.n_cells(dim)))
|
||||
print("Lifting random cochain dim ", dim, flush=True)
|
||||
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
||||
print("Check Apl(K) structure of the lifted element: ",a.check(), flush=True)
|
||||
da = a.differential()
|
||||
Diff = cochainComplex.differential(dim)
|
||||
cda = A.cochain_to_vector(da.integral(),dim+1)
|
||||
equal = Diff*v == cda
|
||||
print("Diff*v == cda.integral()", equal, flush=True)
|
||||
if not equal:
|
||||
def check_dif_int(A, S, cochainComplex, v):
|
||||
#print("Lifting random cochain dim ", dim, flush=True)
|
||||
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
||||
a.check() # the method raises an error if the aplk element is not properly built (i.e, the faces do not match)
|
||||
#print("Check Apl(K) structure of the lifted element: ",a.check(), flush=True)
|
||||
da = a.differential()
|
||||
Diff = cochainComplex.differential(dim)
|
||||
cda = A.cochain_to_vector(da.integral(),dim+1)
|
||||
equal = Diff*v == cda
|
||||
#print("Diff*v == cda.integral()", equal, flush=True)
|
||||
if not equal:
|
||||
raise Exception("the integrals are not equal ", flush=True)
|
||||
return -1
|
||||
for cell in S.n_cells(dim+1):
|
||||
d = da.elements[cell.tuple()]
|
||||
#s = (-1)**(dim*(dim-1)//2) # [FHT, RHT, p.129]
|
||||
di = sum([((-1)**(f))*a.elements[cell.face(f).tuple()].integral() for f in range(cell.dimension()+1)])
|
||||
equal = di == d.integral()
|
||||
if equal:
|
||||
None
|
||||
#print("di == d.integral(): ", equal, flush=True)
|
||||
else:
|
||||
raise Exception("the integrals are not equal ", flush=True)
|
||||
|
||||
for cell in S.n_cells(dim+1):
|
||||
d = da.elements[cell.tuple()]
|
||||
#s = (-1)**(dim*(dim-1)//2) # [FHT, RHT, p.129]
|
||||
di = sum([((-1)**(f))*a.elements[cell.face(f).tuple()].integral() for f in range(cell.dimension()+1)])
|
||||
equal = di == d.integral()
|
||||
if equal:
|
||||
print("di == d.integral(): ", equal, flush=True)
|
||||
else:
|
||||
raise Exception("the integrals are not equal ", flush=True)
|
||||
|
||||
return -1
|
||||
return 0
|
||||
|
||||
S = simplicial_complexes.Sphere(7)
|
||||
#S = simplicial_complexes.K3Surface()
|
||||
S.set_immutable()
|
||||
A = AlgebraAplK(S)
|
||||
cochainComplex = S.chain_complex(base_ring=QQ).dual()
|
||||
N = 1
|
||||
for dim in range(5):
|
||||
l = [random_vector(QQ, len(S.n_cells(dim))) for i in range(N)]
|
||||
data = zip_with_constants(A, S, cochainComplex, l)
|
||||
print("Start parallel test at dimension " + str(dim), flush=True)
|
||||
results = [i[1] for i in check_dif_int(data)]
|
||||
|
||||
print("Test finished", flush=True)
|
||||
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user