Upload files to "/"
This commit is contained in:
parent
9b855d71f3
commit
0588ddbccd
144
test_battery.py
Normal file
144
test_battery.py
Normal file
@ -0,0 +1,144 @@
|
||||
from sage.all import *
|
||||
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")
|
||||
"""
|
||||
######### RUN MINIMAL MODEL ALGORITHM
|
||||
"""
|
||||
[sullivan_model, model_morphism, cohomology_correspondence] = minimal_model(S, max_depth=12000, max_dim=3)
|
||||
print(sullivan_model, flush=True)
|
||||
save(sullivan_model, "sullivan_model_K3_deg3")
|
||||
save(model_morphism,"model_morphism_K3_deg3")
|
||||
save(cohomology_correspondence,"cohomology_correspondence_K3_deg3")
|
||||
"""
|
||||
######### TEST APLK STRUCTURE
|
||||
"""
|
||||
@parallel(ncpus=Integer(24))
|
||||
def check(gen, aplk):
|
||||
print("Checking the aplk element " + str(gen), flush=True)
|
||||
aplk.check()
|
||||
return 0
|
||||
|
||||
for k in smorphism.keys():
|
||||
elements = list(smorphism[k].items())
|
||||
print("Start parallel check", flush=True)
|
||||
results = [i[1] for i in check(elements)]
|
||||
"""
|
||||
########## TEST DIFFERENTIAL/PHI COMMUTING
|
||||
"""
|
||||
for degree in range(2,4):
|
||||
for g in smodel.basis(degree):
|
||||
phi_g = smorphism[degree][str(g)]
|
||||
d_phi_g = phi_g.differential()
|
||||
dg = g.differential()
|
||||
phi_d_g = phi_polinomial(dg, smorphism, A)
|
||||
equal = phi_d_g == d_phi_g
|
||||
if not equal:
|
||||
raise ValueError("(phi o dif)(" + str(g) + ") != (dif o phi)(" + str(g) + ")")
|
||||
else:
|
||||
print("(phi o dif)(" + str(g) + ") == (dif o phi)(" + str(g) + ")", flush=True)
|
||||
"""
|
||||
######### TEST LIFTING/INTEGRAL RANDOM COCHAINS
|
||||
"""
|
||||
def zip_with_constants(a, b, l):
|
||||
return [(a, b, i) for i in l]
|
||||
|
||||
@parallel(ncpus=Integer(24))
|
||||
def check_lifting(A, dim, v):
|
||||
print("Lift random cochain to Apl(K)", flush=True)
|
||||
a = A.lift_cochain(A.vector_to_cochain(v,dim))
|
||||
print("Checking Apl(K) structure of the random element ", flush=True)
|
||||
a.check()
|
||||
print("Checking if the integral is equal to the original cochain", flush=True)
|
||||
equal = A.cochain_to_vector(a.integral(), dim) == v
|
||||
if not equal:
|
||||
raise ValueError("the cochains are not equal")
|
||||
return -1
|
||||
else:
|
||||
print("OK", flush=True)
|
||||
return 0
|
||||
|
||||
N = 100
|
||||
for dim in range(5):
|
||||
random_cochains = [random_vector(QQ, len(S.n_cells(dim))) for i in range(N)]
|
||||
data = zip_with_constants(A, dim, random_cochains)
|
||||
print("Start parallel lifting at dimension " + str(dim), flush=True)
|
||||
results = [i[1] for i in check_lifting(data)]
|
||||
print("Finished battery test", flush=True)
|
||||
"""
|
||||
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION APLn
|
||||
|
||||
def random_pol(apln):
|
||||
n = apln.n
|
||||
coef = randint(1,10)
|
||||
exp = tuple([randint(0,5) for i in range(n)] + [0]*n)
|
||||
gens = apln.gens()
|
||||
return apln.get_term(apln, coef, exp, gens)
|
||||
|
||||
n = 4
|
||||
s = SimplicialAlgebraplN(n)
|
||||
s.inject_variables()
|
||||
#cofaces = [x for x in list(powerset(range(n+1)) if len(x) == n]
|
||||
|
||||
dp = random_pol(s)*prod(s.gens()[s.n+2:])
|
||||
p = dp.solve_primitive().reduce()
|
||||
fd = sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])
|
||||
print("sum([((-1)**f)*p.face(f).integral() for f in range(n+1)])== dq.integral(): ", fd == dp.integral(), flush=True)
|
||||
|
||||
for f in range(n+1):
|
||||
coface = list(range(n+2))
|
||||
coface.remove(f)
|
||||
q = dp.propagate(coface,n+1)
|
||||
dq = q.differential().reduce()
|
||||
#p = dp.solve_primitive().reduce()
|
||||
#print("p.differential().reduce() == dp.reduce()", p.differential().reduce() == dp.reduce(), flush=True)
|
||||
#print("q.face("+str(f)+") == p", flush=True)
|
||||
#print(q.face(f).reduce() == p, flush=True)
|
||||
print("(-1)**"+str(f)+")*p.face().integral() == dq.integral(): ", ((-1)**f)*dp.integral() == dq.integral(), flush=True)
|
||||
#print(p.integral() == dq.integral(), flush=True)
|
||||
|
||||
|
||||
|
||||
######### TEST DIFFERENTIAL/INTEGRAL COMMUTATION WITH RANDOM COCHAINS
|
||||
"""
|
||||
def zip_with_constants(a, b, c, l):
|
||||
return [(a, b, c, i) for i in l]
|
||||
|
||||
@parallel(ncpus=Integer(24))
|
||||
def check(A, Diff, degree, cochain):
|
||||
#PARAMS:
|
||||
# - Diff: Differential at dimension "dim"
|
||||
# - f: tuple (str,Apl(K))
|
||||
# -
|
||||
f = A.lift_cochain(A.vector_to_cochain(cochain,degree))
|
||||
#print("Checking (DoI)f == (IoD)f ", flush=True)
|
||||
cf = A.cochain_to_vector(f.integral(), degree)
|
||||
df = f.differential()
|
||||
cdf = A.cochain_to_vector(df.integral(), degree + 1)
|
||||
equal = Diff*cf == cdf
|
||||
if not equal:
|
||||
#raise ValueError("the cochains are not equal at degree " + str(degree))
|
||||
print("the cochains are not equal at degree " + str(degree))
|
||||
return -1
|
||||
#else:
|
||||
# print("OK", flush=True)
|
||||
return 0
|
||||
|
||||
N = 10
|
||||
for degree in range(5):
|
||||
random_cochains = [random_vector(QQ, len(S.n_cells(degree))) for i in range(N)]
|
||||
Diff = cochainComplex.differential(degree)
|
||||
data = zip_with_constants(A, Diff, degree, random_cochains)
|
||||
print("Start parallel DIFF/INTEGRAL at degree " + str(degree), flush=True)
|
||||
results = [i[1] for i in check(data)]
|
||||
print("Finished battery test", flush=True)
|
||||
"""
|
||||
Loading…
Reference in New Issue
Block a user