CalabiYau
CalabiYau
¶
A Calabi-Yau manifold in a toric variety.
This class handles various computations relating to the Calabi-Yau manifold itself. It can be used to compute intersection numbers and the toric Mori and Kähler cones, among other things. The Calabi-Yau is either the anticanonical hypersurface of its ambient toric variety or, if a nef partition is specified, the corresponding complete intersection.
Warning
Generally, objects of this class should not be constructed directly by
the end user. Instead, they should be created with the
get_cy method of
ToricVariety or the
get_cy method of
Triangulation.
Tip
This package is focused on computations on Calabi-Yau 3-fold hypersurfaces, but there is experimental support for Calabi-Yaus of other dimensions, for non-favorable ones, and for complete intersections. See experimental features for more details.
Parameters:
-
toric_var(ToricVariety) –The ambient toric variety of the Calabi-Yau. For hypersurfaces, its defining triangulation must be fine and use either all the points of the polytope not interior to facets, or all of its points.
-
nef_partition(list[tuple[int, ...]] | None, default:None) –A nef partition of the polytope, given as a list of tuples of indices of points of the polytope, which defines a complete intersection Calabi-Yau. If not specified, the anticanonical hypersurface is constructed.
Raises:
-
ValueError–If
nef_partitiondoes not define a nef partition, if the triangulation is not fine (for hypersurfaces), or if the triangulation does not use a valid set of points (for hypersurfaces). -
Exception–If the experimental features are not enabled and a nef partition is given, the Calabi-Yau is not a 3-fold, or the polytope is not favorable.
Examples:
We construct a Calabi-Yau from a fine, regular, star triangulation of a
polytope. Since this class is not intended to be initialized by the end
user, we create it with the
get_cy method of
Triangulation. In this example
we obtain the quintic hypersurface in \(\mathbb{P}^4\).
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-1,-1]])
>>> t = p.triangulate()
>>> t.get_cy()
A Calabi-Yau 3-fold hypersurface with h11=1 and h21=101 ...
Methods:
-
ambient_dimension–Return the complex dimension of the ambient toric variety.
-
ambient_variety–Return the ambient toric variety.
-
chi–Compute the Euler characteristic of the Calabi-Yau.
-
clear_cache–Clear the cached results of any previous computation.
-
compute_curve_volumes–Compute the volumes of the generators of the toric Mori cone.
-
compute_cy_volume–Compute the volume of the Calabi-Yau at a location in the Kähler cone.
-
compute_divisor_volumes–Compute the volumes of divisors at a location in the Kähler cone.
-
compute_gvs–Compute the genus-zero Gopakumar-Vafa invariants of the Calabi-Yau.
-
compute_gws–Compute the genus-zero Gromov-Witten invariants of the Calabi-Yau.
-
compute_inverse_kahler_metric–Compute the inverse Kähler metric at a location in the Kähler cone.
-
compute_kahler_metric–Compute the Kähler metric at a location in the Kähler cone.
-
compute_kappa_matrix–Compute the matrix \(\kappa_{ijk}t^k\) at a location in the Kähler cone.
-
compute_kappa_vector–Compute the vector \(\kappa_{ijk}t^j t^k\) at a location in the Kähler cone.
-
curve_basis–Return the current basis of curves of the Calabi-Yau.
-
dimension–Return the complex dimension of the Calabi-Yau.
-
divisor_basis–Return the current basis of divisors of the Calabi-Yau.
-
glsm_charge_matrix–Compute the GLSM charge matrix of the Calabi-Yau.
-
glsm_linear_relations–Compute the linear relations among the columns of the GLSM charge matrix.
-
h11–Return the Hodge number \(h^{1,1}\) of the Calabi-Yau.
-
h12–Return the Hodge number \(h^{1,2}\) of the Calabi-Yau.
-
h13–Return the Hodge number \(h^{1,3}\) of the Calabi-Yau.
-
h22–Return the Hodge number \(h^{2,2}\) of the Calabi-Yau.
-
hpq–Return the Hodge number \(h^{p,q}\) of the Calabi-Yau.
-
intersection_numbers–Return the intersection numbers of the Calabi-Yau.
-
is_smooth–Return whether the Calabi-Yau is smooth.
-
is_trivially_equivalent–Check if the Calabi-Yaus are trivially equivalent.
-
mori_cone_cap–Return the Mori cone cap of the Calabi-Yau.
-
polytope–Return the polytope whose triangulation gives rise to the ambient variety.
-
prime_toric_divisors–Return the indices of the prime toric divisors that intersect the Calabi-Yau.
-
second_chern_class–Compute the second Chern class of the Calabi-Yau.
-
set_curve_basis–Set a basis of curves of the Calabi-Yau.
-
set_divisor_basis–Set a basis of divisors of the Calabi-Yau.
-
toric_effective_cone–Return the effective cone inferred from toric geometry.
-
toric_kahler_cone–Return the Kähler cone inferred from toric geometry.
-
toric_mori_cone–Return the Mori cone inferred from toric geometry.
-
triangulation–Return the triangulation giving rise to the ambient toric variety.
ambient_dimension
¶
Return the complex dimension of the ambient toric variety.
Also available as ambient_dim.
Returns:
-
int–The complex dimension of the ambient toric variety.
Examples:
We construct a Calabi-Yau and find the dimension of its ambient variety.
ambient_variety
¶
Return the ambient toric variety.
Returns:
-
ToricVariety–The ambient toric variety.
Examples:
We construct a Calabi-Yau hypersurface in a toric variety and check that this function returns the ambient variety.
chi
¶
Compute the Euler characteristic of the Calabi-Yau.
For hypersurfaces, it is computed from the polytope (see
Polytope.chi). For complete
intersections, it is computed as the alternating sum of the Hodge numbers,
which are computed with PALP.
Note
For hypersurfaces, only Calabi-Yaus of dimension 2-4 are supported.
Returns:
-
int–The Euler characteristic of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau hypersurface and compute its Euler characteristic.
clear_cache
¶
Clear the cached results of any previous computation.
Note that clearing the full cache also resets the bases of divisors and curves.
Parameters:
-
recursive(bool, default:False) –Whether to also clear the cache of the ambient toric variety, defining triangulation, and polytope. This is ignored when
only_in_basis=True. -
only_in_basis(bool, default:False) –Whether to only clear the cache of computations that depend on the choice of basis.
Examples:
We construct a Calabi-Yau hypersurface, compute its toric Mori cone, clear the cache, and then compute it again.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.toric_mori_cone()
A 2-dimensional rational polyhedral cone in RR^7 generated by 3 rays
>>> cy.clear_cache() # Clears the cached result
>>> cy.toric_mori_cone() # The Mori cone is recomputed
A 2-dimensional rational polyhedral cone in RR^7 generated by 3 rays
compute_curve_volumes
¶
Compute the volumes of the generators of the toric Mori cone.
The curves correspond to the (not necessarily minimal) generators of the
Mori cone inferred from toric geometry in the current basis of curves
(i.e. the rays of toric_mori_cone(in_basis=True), see
toric_mori_cone). The
volume of a curve \(C\) is \(t^i C_i\).
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
-
only_extremal(bool, default:False) –Whether to only use the extremal rays of the Mori cone.
Returns:
-
ndarray–The volumes of the curves, in the same order as the rays of the cone.
Examples:
We construct a Calabi-Yau hypersurface and find the volumes of the generators of the Mori cone at the tip of the stretched Kähler cone.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> tip = cy.toric_kahler_cone().tip_of_stretched_cone(1)
>>> cy.compute_curve_volumes(tip)
array([1., 4., 1.])
As expected, all generators of the Mori cone have volumes greater than or equal to 1 (up to rounding errors) at the tip of the stretched Kähler cone.
compute_cy_volume
¶
Compute the volume of the Calabi-Yau at a location in the Kähler cone.
The volume is given by \(\mathcal{V} = \frac{1}{6}\kappa_{ijk}t^i t^j t^k\), where \(\kappa_{ijk}\) are the intersection numbers in the current basis of divisors.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
Returns:
-
float–The volume of the Calabi-Yau at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and find its volume at the tip of the stretched Kähler cone.
compute_divisor_volumes
¶
Compute the volumes of divisors at a location in the Kähler cone.
The volume of the \(i\)-th basis divisor is given by \(\tau_i = \frac{1}{2}\kappa_{ijk}t^j t^k\), where \(\kappa_{ijk}\) are the intersection numbers in the current basis of divisors. The volumes of the prime toric divisors are obtained by expressing them in terms of the basis divisors.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
-
in_basis(bool, default:False) –Whether to compute the volumes of the current basis of divisors. Otherwise, the volumes of all the prime toric divisors are computed.
Returns:
-
ndarray–The volumes of the prime toric divisors or of the basis divisors at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and find the volumes of the prime toric divisors and of the basis divisors at the tip of the stretched Kähler cone.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> tip = cy.toric_kahler_cone().tip_of_stretched_cone(1)
>>> cy.compute_divisor_volumes(tip)
array([ 2.5, 24. , 16. , 2.5, 2.5, 0.5])
>>> cy.compute_divisor_volumes(tip, in_basis=True)
array([2.5, 0.5])
compute_gvs
¶
compute_gvs(mcap_generators=None, grading_vec=None, max_deg=None, min_points=None, target_points=None, basis=None, format=None)
Compute the genus-zero Gopakumar-Vafa invariants of the Calabi-Yau.
The computation is performed with
cygv. The charges of the curves are
expressed in the current basis of curves (see
curve_basis). At most one of
max_deg, min_points, and target_points can be specified. If none of
them is, the invariants are computed only for the charges in
mcap_generators.
Also available as compute_gv.
Parameters:
-
mcap_generators(ArrayLike | None, default:None) –Generators of the cone of charges to consider (typically the Mori cone cap), in the current basis of curves, which are passed to cygv. If none of
max_deg,min_points, andtarget_pointsis specified, the invariants are computed only for these charges, which must then include the origin. If not specified, the rays ofmori_cone_cap(in the current basis) together with at least \(100\,h^{1,1}\) of its lattice points are used. -
grading_vec(ArrayLike | None, default:None) –The grading vector \(g\), which defines the degree of a charge \(q\) as \(q \cdot g\). It must have a positive dot product with all the generators of the Mori cone cap. If not specified, one is found with
Cone.find_grading_vector. -
max_deg(int | None, default:None) –The maximum degree up to which the invariants are computed.
-
min_points(int | None, default:None) –The minimum number of invariants to compute. The maximum degree is increased until at least this many are found.
-
target_points(ArrayLike | None, default:None) –Charges, in the current basis of curves, for which to compute the invariants. Invariants of other charges may be computed as well.
-
basis(ndarray | None, default:None) –A matrix used to change the basis of the charges in the returned
Invariantsobject, where each charge \(q\) is replaced bybasis @ q. It is ignored ifformatis specified. -
format(str | None, default:None) –The output format. If
"dok", a dictionary mapping charges to invariants is returned. If"coo", a list of rows of the form[q_1, ..., q_n, invariant]is returned. If not specified, anInvariantsobject is returned.
Returns:
-
Invariants | dict[tuple[int, ...], int] | list[list[int]]–The GV invariants, in the format specified by
format.
Raises:
-
ValueError–If more than one of
max_deg,min_points, andtarget_pointsis specified, or if none of them is specified andmcap_generatorsis not specified or does not include the origin.
Examples:
We construct a Calabi-Yau hypersurface and compute its GV invariants up to degree 2.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> gvs = cy.compute_gvs(max_deg=2)
>>> gvs
N=5 gv-invariants calculated for a Calabi-Yau 3-fold hypersurface ...
>>> gvs.gv((0, 1))
540
>>> sorted(cy.compute_gvs(max_deg=1, format="dok").items())
[((0, 1), 540), ((1, -3), 3)]
compute_gws
¶
compute_gws(mcap_generators=None, grading_vec=None, max_deg=None, min_points=None, target_points=None, basis=None, format=None)
Compute the genus-zero Gromov-Witten invariants of the Calabi-Yau.
The computation is performed with
cygv. The charges of the curves are
expressed in the current basis of curves (see
curve_basis). At most one of
max_deg, min_points, and target_points can be specified. If none of
them is, the invariants are computed only for the charges in
mcap_generators. The invariants are rational numbers, given as
fractions.Fraction objects.
Also available as compute_gw.
Parameters:
-
mcap_generators(ArrayLike | None, default:None) –Generators of the cone of charges to consider (typically the Mori cone cap), in the current basis of curves, which are passed to cygv. If none of
max_deg,min_points, andtarget_pointsis specified, the invariants are computed only for these charges, which must then include the origin. If not specified, the rays ofmori_cone_cap(in the current basis) together with at least \(100\,h^{1,1}\) of its lattice points are used. -
grading_vec(ArrayLike | None, default:None) –The grading vector \(g\), which defines the degree of a charge \(q\) as \(q \cdot g\). It must have a positive dot product with all the generators of the Mori cone cap. If not specified, one is found with
Cone.find_grading_vector. -
max_deg(int | None, default:None) –The maximum degree up to which the invariants are computed.
-
min_points(int | None, default:None) –The minimum number of invariants to compute. The maximum degree is increased until at least this many are found.
-
target_points(ArrayLike | None, default:None) –Charges, in the current basis of curves, for which to compute the invariants. Invariants of other charges may be computed as well.
-
basis(ndarray | None, default:None) –A matrix used to change the basis of the charges in the returned
Invariantsobject, where each charge \(q\) is replaced bybasis @ q. It is ignored ifformatis specified. -
format(str | None, default:None) –The output format. If
"dok", a dictionary mapping charges to invariants is returned. If"coo", a list of rows of the form[q_1, ..., q_n, invariant]is returned. If not specified, anInvariantsobject is returned.
Returns:
-
Invariants | dict[tuple[int, ...], Fraction] | list[list]–The GW invariants, in the format specified by
format.
Raises:
-
ValueError–If more than one of
max_deg,min_points, andtarget_pointsis specified, or if none of them is specified andmcap_generatorsis not specified or does not include the origin.
Examples:
We construct a Calabi-Yau hypersurface and compute its GW invariants up to degree 2.
compute_inverse_kahler_metric
¶
Compute the inverse Kähler metric at a location in the Kähler cone.
It is computed as \(K^{ij} = 4\left(\tau_i\tau_j - \mathcal{V}\kappa_{ijk}t^k\right)\), where \(\mathcal{V}\) is the volume of the Calabi-Yau, \(\tau_i\) are the volumes of the basis divisors, and \(\kappa_{ijk}\) are the intersection numbers in the current basis of divisors.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
Returns:
-
ndarray–The inverse Kähler metric at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and compute the inverse Kähler metric at the tip of the stretched Kähler cone.
compute_kahler_metric
¶
Compute the Kähler metric at a location in the Kähler cone.
It is computed by inverting the result of compute_inverse_kahler_metric.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
Returns:
-
ndarray–The Kähler metric at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and compute the Kähler metric at the tip of the stretched Kähler cone.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> tip = cy.toric_kahler_cone().tip_of_stretched_cone(1)
>>> cy.compute_kahler_metric(tip)
array([[0.10969388, 0.02295918],
[0.02295918, 0.02806122]])
compute_kappa_matrix
¶
Compute the matrix \(\kappa_{ijk}t^k\) at a location in the Kähler cone.
Here \(\kappa_{ijk}\) are the intersection numbers in the current basis of divisors.
Also available as compute_AA.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
Returns:
-
ndarray–The matrix \(\kappa_{ijk}t^k\) at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and compute this matrix at the tip of the stretched Kähler cone.
compute_kappa_vector
¶
Compute the vector \(\kappa_{ijk}t^j t^k\) at a location in the Kähler cone.
Here \(\kappa_{ijk}\) are the intersection numbers in the current basis of divisors.
Note
This function only supports Calabi-Yau 3-folds.
Parameters:
-
tloc(ArrayLike) –A vector specifying a location in the Kähler cone, in the current basis of divisors.
Returns:
-
ndarray–The vector \(\kappa_{ijk}t^j t^k\) at the specified location.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and compute this vector at the tip of the stretched Kähler cone.
curve_basis
¶
Return the current basis of curves of the Calabi-Yau.
If no basis has been set, a default integral basis of divisors is chosen and set, and its dual basis of curves is returned.
Parameters:
-
include_origin(bool, default:True) –Whether the indexing of the returned vector (or the columns of the returned matrix) includes the origin, i.e. the canonical divisor at index 0.
-
as_matrix(bool, default:False) –Whether to return the basis as a matrix instead of a vector of indices. If a generic (matrix) basis was set, then it is always returned as a matrix.
Returns:
-
ndarray–A vector of indices of the standard basis of the lattice dual to the lattice of prime toric divisors that form the basis of curves. If
as_matrixis true, or if a generic basis has been set withset_divisor_basisorset_curve_basis, a matrix is returned instead, where each row gives the intersection numbers of a basis curve with the canonical divisor and the prime toric divisors.
Raises:
-
ValueError–If
include_origin=Falsebut the current basis includes the index of the canonical divisor.
Examples:
We consider a simple Calabi-Yau with two independent curves. If no basis has been set, then this function finds one. If a basis has been set, then this function returns it.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.curve_basis() # We haven't set any basis
array([5, 6])
>>> cy.set_curve_basis([5,6]) # Here we set a basis
>>> cy.curve_basis() # We get the basis we set
array([5, 6])
>>> cy.curve_basis(as_matrix=True) # We get the basis in matrix form
array([[-18, 1, 9, 6, 1, 1, 0],
[ -6, 0, 3, 2, 0, 0, 1]])
dimension
¶
Return the complex dimension of the Calabi-Yau.
For hypersurfaces, this is one less than the dimension of the ambient variety. For complete intersections, it is the dimension of the ambient variety minus the number of parts of the nef partition. The result is cached.
Also available as dim.
Returns:
-
int–The complex dimension of the Calabi-Yau.
Examples:
We construct a Calabi-Yau and find its dimension.
divisor_basis
¶
Return the current basis of divisors of the Calabi-Yau.
If no basis has been set, a default integral basis of prime toric divisors
is chosen and set. A different basis can be set with
set_divisor_basis or
set_curve_basis.
Parameters:
-
include_origin(bool, default:True) –Whether the indexing of the returned vector (or the columns of the returned matrix) includes the origin, i.e. the canonical divisor at index 0.
-
as_matrix(bool, default:False) –Whether to return the basis as a matrix instead of a vector of indices of prime toric divisors. If a generic (matrix) basis was set, then it is always returned as a matrix.
Returns:
-
ndarray–A vector of the indices of the prime toric divisors that form the basis. If
as_matrixis true, or if a generic (matrix) basis has been set, a matrix is returned instead, where each row is a basis element expressed as a linear combination of the canonical divisor and the prime toric divisors.
Raises:
-
ValueError–If
include_origin=Falsebut the current basis includes the canonical divisor.
Examples:
We consider a simple Calabi-Yau with two independent divisors. If no basis has been set, then this function finds one. If a basis has been set, then this function returns it.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.divisor_basis() # We haven't set any basis
array([5, 6])
>>> cy.set_divisor_basis([5,6]) # Here we set a basis
>>> cy.divisor_basis() # We get the basis we set
array([5, 6])
>>> cy.divisor_basis(as_matrix=True) # We get the basis in matrix form
array([[0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 1]])
glsm_charge_matrix
¶
Compute the GLSM charge matrix of the Calabi-Yau.
The columns correspond to the canonical divisor (the origin of the
polytope) followed by the prime toric divisors that intersect the
Calabi-Yau (see
prime_toric_divisors).
Each row is a linear relation among the corresponding points of the
polytope, with one row per independent \(U(1)\) charge. The result is cached,
and a copy is returned.
Parameters:
-
include_origin(bool, default:True) –Whether to include the column corresponding to the origin, i.e. the canonical divisor.
Returns:
-
ndarray–The GLSM charge matrix.
Examples:
We construct a Calabi-Yau hypersurface and compute its GLSM charge matrix.
glsm_linear_relations
¶
Compute the linear relations among the columns of the GLSM charge matrix.
Each row is a vector of coefficients \(r\) such that
\(\sum_j r_j Q_{\cdot j} = 0\), where \(Q\) is the GLSM charge matrix returned
by glsm_charge_matrix.
The columns follow the same ordering as the columns of the charge matrix.
The result is cached, and a copy is returned.
Parameters:
-
include_origin(bool, default:True) –Whether to include the origin (i.e. the canonical divisor). If false, the first row and the first column of the matrix are removed.
Returns:
-
ndarray–A matrix whose rows are linear relations among the columns of the GLSM charge matrix.
Examples:
We construct a Calabi-Yau hypersurface and compute the GLSM linear relations. By definition, their product with the transposed charge matrix must vanish.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.glsm_linear_relations()
array([[ 1, 0, 0, 0, 0, 18, 6],
[ 0, 1, 0, 0, 0, -1, 0],
[ 0, 0, 1, 0, 0, -9, -3],
[ 0, 0, 0, 1, 0, -6, -2],
[ 0, 0, 0, 0, 1, -1, 0]])
>>> cy.glsm_linear_relations().dot(cy.glsm_charge_matrix().T)
array([[0, 0],
[0, 0],
[0, 0],
[0, 0],
[0, 0]])
h11
¶
Return the Hodge number \(h^{1,1}\) of the Calabi-Yau.
Note
For hypersurfaces, the Hodge numbers are computed from the polytope
(see Polytope.hpq), and only
Calabi-Yaus of dimension 2-4 are supported. For complete intersections,
they are computed with PALP.
Returns:
-
int–The Hodge number \(h^{1,1}\) of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau hypersurface and compute its \(h^{1,1}\).
h12
¶
Return the Hodge number \(h^{1,2}\) of the Calabi-Yau.
Also available as h21.
Note
For hypersurfaces, the Hodge numbers are computed from the polytope
(see Polytope.hpq), and only
Calabi-Yaus of dimension 2-4 are supported. For complete intersections,
they are computed with PALP.
Returns:
-
int–The Hodge number \(h^{1,2}\) of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau hypersurface and compute its \(h^{1,2}\).
h13
¶
Return the Hodge number \(h^{1,3}\) of the Calabi-Yau.
Also available as h31.
Note
For hypersurfaces, the Hodge numbers are computed from the polytope
(see Polytope.hpq), and only
Calabi-Yaus of dimension 2-4 are supported. For complete intersections,
they are computed with PALP.
Returns:
-
int–The Hodge number \(h^{1,3}\) of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau 4-fold hypersurface, which requires enabling the experimental features, and compute its \(h^{1,3}\).
h22
¶
Return the Hodge number \(h^{2,2}\) of the Calabi-Yau.
This is mainly of interest for Calabi-Yau 4-folds. For 3-folds it
is currently returned as 0 (see the warning in
hpq).
Note
For hypersurfaces, the Hodge numbers are computed from the polytope
(see Polytope.hpq), and only
Calabi-Yaus of dimension 2-4 are supported. For complete intersections,
they are computed with PALP.
Returns:
-
int–The Hodge number \(h^{2,2}\) of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau 4-fold hypersurface, which requires enabling the experimental features, and compute its \(h^{2,2}\).
hpq
¶
Return the Hodge number \(h^{p,q}\) of the Calabi-Yau.
Hodge numbers with indices outside the Hodge diamond are returned as 0.
Note
For hypersurfaces, the Hodge numbers are computed from the polytope
(see Polytope.hpq), and only
Calabi-Yaus of dimension 2-4 are supported. For complete
intersections, they are computed with PALP.
Warning
For hypersurfaces, only the Hodge numbers with \(p+q\) not greater than the dimension of the Calabi-Yau are currently computed correctly. The remaining ones are returned as 0, even though they are related to the others by \(h^{p,q}=h^{n-p,n-q}\), where \(n\) is the dimension.
Parameters:
-
p(int) –The holomorphic index of the Dolbeault cohomology of interest.
-
q(int) –The anti-holomorphic index of the Dolbeault cohomology of interest.
Returns:
-
int–The Hodge number \(h^{p,q}\) of the Calabi-Yau.
Raises:
-
NotImplementedError–If the Calabi-Yau is a hypersurface whose dimension is not 2, 3, or 4, or if it is a complete intersection whose Hodge numbers cannot be computed.
Examples:
We construct a Calabi-Yau and check some of its Hodge numbers.
intersection_numbers
¶
intersection_numbers(in_basis=False, format='dok', zero_as_anticanonical=False, backend='all', check=True, backend_error_tol=0.001, round_to_zero_threshold=0.001, round_to_integer_error_tol=0.05, verbose=0, exact_arithmetic=False)
Return the intersection numbers of the Calabi-Yau.
The indices refer to the canonical divisor of the ambient variety (index
0) and the prime toric divisors that intersect the Calabi-Yau (indices
1, 2, ..., in the order given by
prime_toric_divisors),
all restricted to the Calabi-Yau. They are computed from the
intersection numbers
of the ambient variety. For hypersurfaces,
\(\kappa_{ijk\cdots} = -\kappa^{V}_{0ijk\cdots}\), where \(\kappa^{V}\) are
the intersection numbers of the ambient variety. For
complete intersections, the ambient intersection numbers are successively
restricted to each part of the nef partition.
Only the nonzero intersection numbers are stored, and the results are
cached for each combination of in_basis, format,
zero_as_anticanonical, and exact_arithmetic. The remaining parameters
only affect the first computation.
Tip
The intersection numbers are integers when the Calabi-Yau is smooth.
Otherwise, they are computed as floating-point numbers, but there is
the experimental option to turn them into exact rationals with
exact_arithmetic=True. The process is fairly quick, but it is
unreliable at large \(h^{1,1}\). Furthermore, verifying that they are
correct becomes very slow at large \(h^{1,1}\).
Parameters:
-
in_basis(bool, default:False) –Whether to return the intersection numbers in the current basis of divisors (see
divisor_basis). In this case, the indices refer to the basis elements. -
format(str, default:'dok') –The output format of the intersection numbers. The options are
"dok","coo", and"dense". When set to"dok"(Dictionary Of Keys), a dictionary is returned where the keys are tuples of divisor indices in ascending order and the values are the corresponding intersection numbers. When set to"coo"(COOrdinate format), a numpy array is returned with rows of the form[a, b, ..., c, K_ab...c], i.e. all but the last entry of each row are divisor indices in ascending order, and the last entry is their intersection number. When set to"dense", the full dense array of intersection numbers is returned. -
zero_as_anticanonical(bool, default:False) –Whether to treat the zeroth index as corresponding to the anticanonical divisor instead of the canonical divisor. This is ignored when
in_basis=True. -
backend(str, default:'all') –The sparse linear solver to use. Options are
"all","sksparse", and"scipy". When set to"all", every solver is tried in order until one succeeds. -
check(bool, default:True) –Whether to explicitly check the solution to the linear system.
-
backend_error_tol(float, default:0.001) –Error tolerance for the solution of the linear system.
-
round_to_zero_threshold(float, default:0.001) –Intersection numbers with magnitude smaller than this threshold are rounded to zero (i.e. dropped).
-
round_to_integer_error_tol(float, default:0.05) –Maximum allowed distance from an integer for intersection numbers that are expected to be integral. For complete intersections, the Calabi-Yau is considered smooth if all of its intersection numbers are within this distance of an integer.
-
verbose(int, default:0) –The verbosity level. If 0, nothing is printed. If 1 or higher, warnings from the linear backends are printed.
-
exact_arithmetic(bool, default:False) –Whether to convert the intersection numbers into exact rational numbers (
flint.fmpq). This requires the experimental features to be enabled.
Returns:
-
dict[tuple[int, ...], int | float] | ndarray–The intersection numbers in the requested format: a dictionary for
"dok", a 2D array for"coo", or a dense array of rank equal to the dimension of the Calabi-Yau for"dense". A shallow copy of the cached result is returned.
Raises:
-
ValueError–If
formatorbackendis not a valid option, or ifexact_arithmetic=Trueand the experimental features are not enabled. -
RuntimeError–If the intersection numbers of the ambient variety could not be computed.
-
NotImplementedError–If the Calabi-Yau is a complete intersection of an unsupported type.
Examples:
We construct a Calabi-Yau hypersurface and compute its intersection numbers. By default, the intersection numbers of the canonical divisor (index 0) and the prime toric divisors are returned as a dictionary whose keys are the divisor indices in ascending order.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> intnums = cy.intersection_numbers()
>>> intnums[(1, 2, 3)]
18
>>> intnums[(0, 0, 0)]
-1944
We can also compute the intersection numbers in the current basis of
divisors. In this case, the indices refer to the basis elements, so
(0, 0, 1) corresponds to the intersection of divisors 5, 5, and 6.
>>> cy.divisor_basis()
array([5, 6])
>>> cy.intersection_numbers(in_basis=True)
{(0, 1, 1): -3, (1, 1, 1): 9, (0, 0, 1): 1}
Other output formats are also available. In the "coo" format, all but
the last entry of each row are the indices and the last entry is the
intersection number. The "dense" format gives the full array.
is_smooth
¶
Return whether the Calabi-Yau is smooth.
For hypersurfaces, this is determined by whether the canonical divisor of the ambient variety is smooth. For complete intersections, it is determined while computing the intersection numbers, by checking whether they are all integral. The result is cached.
Returns:
-
bool–Whether the Calabi-Yau is smooth.
Examples:
We construct a Calabi-Yau hypersurface and check if it is smooth.
is_trivially_equivalent
¶
Check if the Calabi-Yaus are trivially equivalent.
Two Calabi-Yau hypersurfaces are trivially equivalent if they come from the same polytope and the restrictions of their triangulations to codimension-2 faces are the same, up to automorphisms of the polytope. This function is only implemented for CY hypersurfaces.
Warning
This function only provides a fairly trivial equivalence check. When
it returns False, the Calabi-Yaus may still be equivalent, which
could, for example, only become evident after a change of basis. The
full equivalence check is generically very difficult, so it is not
implemented.
Parameters:
-
other(CalabiYau) –The other CY that is being compared.
Returns:
-
bool–Whether the CYs are trivially equivalent.
NotImplementedis returned if either of them is a complete intersection.
Examples:
We construct two Calabi-Yaus and compare them. We also show how to get the set of Calabi-Yaus that are not trivially equivalent. As previously mentioned, if two CYs are not trivially equivalent it does not mean that they are actually inequivalent, as there might exist some more complicated transformation that relates them.
>>> from cytools import Polytope
>>> p = Polytope([[-1,0,0,0],[-1,1,0,0],[-1,0,1,0],[2,-1,0,-1],[2,0,-1,-1],
... [2,-1,-1,-1],[-1,0,0,1],[-1,1,0,1],[-1,0,1,1]])
>>> triangs = p.all_triangulations(as_list=True)
>>> cy0 = triangs[0].get_cy()
>>> cy1 = triangs[1].get_cy()
>>> cy0.is_trivially_equivalent(cy1) # Not necessarily inequivalent
False
>>> cys_not_triv_eq = {t.get_cy() for t in triangs}
>>> len(triangs), len(cys_not_triv_eq) # Many are trivially equivalent
(102, 5)
mori_cone_cap
¶
Return the Mori cone cap of the Calabi-Yau.
This is the intersection of the toric Mori cones of all the regular star
triangulations of the polytope that restrict to the same triangulations of
its 2-faces as the defining triangulation. Since all of these
triangulations give rise to the same Calabi-Yau hypersurface, this cone
contains the Mori cone of the Calabi-Yau, and it is generally smaller than
the one returned by
toric_mori_cone. Without
a basis, the coordinates correspond to the points of the triangulation,
with the origin (i.e. the canonical divisor) first.
Note
This method is provisional and may change in future versions.
Parameters:
-
in_basis(bool, default:False) –Whether to express the rays in the current basis of curves (see
curve_basis). If true,exclude_originis ignored. -
exclude_origin(bool, default:False) –Whether to drop the coordinate corresponding to the origin.
-
format(str | None, default:None) –If
"sparse", the matrix of rays is returned as a sparse matrix instead of aCone. This is useful at large \(h^{1,1}\), where constructing aConerequires densifying the rays. Otherwise, aConeis returned. -
verbosity(int, default:0) –The verbosity level.
Returns:
-
Cone | csr_matrix–The Mori cone cap, or the sparse matrix whose rows are its rays if
format="sparse".
Examples:
We construct a Calabi-Yau hypersurface and find its Mori cone cap. In this case it agrees with the toric Mori cone.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.mori_cone_cap(in_basis=True)
A 2-dimensional rational polyhedral cone in RR^2 generated by 3 rays
>>> cy.mori_cone_cap(in_basis=True).rays()
array([[ 1, -3],
[ 1, 0],
[ 0, 1]])
polytope
¶
Return the polytope whose triangulation gives rise to the ambient variety.
Returns:
-
Polytope–The polytope whose triangulation gives rise to the ambient toric variety.
Examples:
We construct a Calabi-Yau and check that the polytope that this function returns is the same as the one we used to construct it.
prime_toric_divisors
¶
Return the indices of the prime toric divisors that intersect the Calabi-Yau.
The indices correspond to points of the polytope, i.e. if \(n\) is in the
returned tuple, then the prime toric divisor corresponding to the \(n\)-th
point in p.points() intersects the Calabi-Yau. Due to the ordering of the
points in the Polytope class, this is simply
(1, 2, ..., k) for hypersurfaces, where k is the number of points not
interior to facets, excluding the origin. For complete intersections, it
may be non-trivial, and it is found by computing the intersection numbers.
The result is cached.
Returns:
-
tuple[int, ...]–The indices of the points of the polytope whose corresponding prime toric divisors intersect the Calabi-Yau.
Examples:
We construct a Calabi-Yau hypersurface and find its prime toric divisors.
second_chern_class
¶
Compute the second Chern class of the Calabi-Yau.
The second Chern class is returned as the vector of its integrals over the canonical divisor and the prime toric divisors, i.e. \(\int_X c_2 \wedge D_k = \sum_{i<j} \kappa_{ijk}\), where the sum runs over pairs of distinct prime toric divisors. The entry corresponding to the canonical divisor is minus the sum of all the others. The result is cached.
Note
This function currently only supports Calabi-Yau 3-folds, and the formula it uses is only valid for hypersurfaces.
Parameters:
-
in_basis(bool, default:False) –Whether to only return the integrals over the current basis of divisors. If true,
include_originis ignored. -
include_origin(bool, default:True) –Whether to include the integral over the canonical divisor as the first entry of the vector.
Returns:
-
ndarray–A vector containing the integrals. It has integer entries if the intersection numbers are integral, and floating-point entries otherwise.
Raises:
-
NotImplementedError–If the Calabi-Yau is not a 3-fold.
Examples:
We construct a Calabi-Yau hypersurface and compute its second Chern class.
set_curve_basis
¶
Set a basis of curves of the Calabi-Yau.
This in turn induces the dual basis of divisors. The basis can be
specified with a vector of indices of the standard basis of the lattice
dual to the lattice of prime toric divisors, which is equivalent to passing
the same vector to
set_divisor_basis. If
the experimental features are enabled, it can also be specified with a
matrix whose rows give the intersection numbers of each basis curve with
the canonical divisor and the prime toric divisors. Cached results that
depend on the choice of basis are cleared.
Note
Only integral bases are supported by CYTools, meaning that all toric curves must be able to be written as an integral linear combination of the basis curves.
Parameters:
-
basis(ArrayLike) –Vector or matrix specifying a basis. When a vector is used, its entries are taken as indices of the standard basis of the lattice dual to the lattice of prime toric divisors (with index 0 corresponding to the canonical divisor). When a matrix is used, its rows are taken as linear combinations of the aforementioned elements. The matrix may omit the column of the canonical divisor, in which case it is computed as minus the sum of the other entries of the row.
-
include_origin(bool, default:True) –Whether to interpret the indices in the input vector as including the origin at index 0. This is only used when
basisis a vector.
Raises:
-
ValueError–If the input does not specify a valid integral basis.
-
Exception–If a matrix is given and the experimental features are not enabled.
Examples:
We consider a simple Calabi-Yau with two independent curves. We first find the default basis of curves it picks and then set a basis of our choice.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.curve_basis() # We haven't set any basis
array([5, 6])
>>> cy.set_curve_basis([5,6]) # Here we set a basis
>>> cy.curve_basis() # We get the basis we set
array([5, 6])
>>> cy.curve_basis(as_matrix=True) # We get the basis in matrix form
array([[-18, 1, 9, 6, 1, 1, 0],
[ -6, 0, 3, 2, 0, 0, 1]])
Note that when setting a curve basis with a vector, this function
behaves exactly the same as
set_divisor_basis.
The two functions differ for generic (matrix) bases. An example can be
found in the experimental
features
section.
set_divisor_basis
¶
Set a basis of divisors of the Calabi-Yau.
This also sets the dual basis of curves. The basis can be specified with a vector of indices of prime toric divisors or, if the experimental features are enabled, with a matrix whose rows are linear combinations of the canonical divisor and the prime toric divisors. Cached results that depend on the choice of basis are cleared.
Note
Only integral bases are supported by CYTools, meaning that all prime toric divisors must be able to be written as an integral linear combination of the basis divisors.
Parameters:
-
basis(ArrayLike) –Vector or matrix specifying a basis. When a vector is used, its entries are taken as the indices of the columns of the GLSM charge matrix (i.e. the canonical divisor at index 0 followed by the prime toric divisors); the indices are sorted before being stored. When a matrix is used, its rows are taken as linear combinations of the aforementioned divisors. The matrix may omit the column of the canonical divisor, in which case its coefficient is set to zero.
-
include_origin(bool, default:True) –Whether to interpret the indices in the input vector as including the origin at index 0. This is only used when
basisis a vector.
Raises:
-
ValueError–If the input does not specify a valid integral basis.
-
Exception–If a matrix is given and the experimental features are not enabled.
Examples:
We consider a simple Calabi-Yau with two independent divisors. We first find the default basis it picks and then we set a basis of our choice.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.divisor_basis() # We haven't set any basis
array([5, 6])
>>> cy.set_divisor_basis([5,6]) # Here we set a basis
>>> cy.divisor_basis() # We get the basis we set
array([5, 6])
>>> cy.divisor_basis(as_matrix=True) # We get the basis in matrix form
array([[0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 1]])
An example with more generic basis choices can be found in the experimental features section.
toric_effective_cone
¶
Return the effective cone inferred from toric geometry.
This is the cone generated by the classes of the prime toric divisors, in the current basis of divisors. The result is cached.
Returns:
-
Cone–The toric effective cone.
Examples:
We construct a Calabi-Yau hypersurface and find its toric effective cone.
toric_kahler_cone
¶
Return the Kähler cone inferred from toric geometry.
This is the dual of the toric Mori cone (see
toric_mori_cone) in the
current basis of divisors. It is contained in the Kähler cone of the
Calabi-Yau.
Returns:
-
Cone–The Kähler cone inferred from toric geometry, in the current basis of divisors.
Examples:
We construct a Calabi-Yau hypersurface and find its Kähler cone.
toric_mori_cone
¶
Return the Mori cone inferred from toric geometry.
This is the Mori cone of the ambient toric variety (or, for complete
intersections, of a toric variety constructed from only the prime toric
divisors that intersect the Calabi-Yau). It contains the Mori cone of the
Calabi-Yau. Each ray is a curve class, given by its intersection numbers
with the canonical divisor and the prime toric divisors, or with the basis
divisors if in_basis=True. The result is cached.
Parameters:
-
in_basis(bool, default:False) –Whether to use the current basis of curves, which is dual to the basis returned by
divisor_basis. If true,include_originis ignored. -
include_origin(bool, default:True) –Whether to include the coordinate corresponding to the origin of the polytope, i.e. the canonical divisor.
Returns:
-
Cone–The Mori cone inferred from toric geometry.
Examples:
We construct a Calabi-Yau hypersurface and find its Mori cone in an \((h^{1,1}+d+1)\)-dimensional lattice, where \(d\) is the dimension of the ambient variety (i.e. without a particular choice of basis), and in an \(h^{1,1}\)-dimensional lattice (i.e. after picking a basis of curves).
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> cy.toric_mori_cone() # By default it does not use a basis of curves
A 2-dimensional rational polyhedral cone in RR^7 generated by 3 rays
>>> cy.toric_mori_cone(in_basis=True) # Dual to the current divisor basis
A 2-dimensional rational polyhedral cone in RR^2 generated by 3 rays
triangulation
¶
Return the triangulation giving rise to the ambient toric variety.
Returns:
-
Triangulation–The triangulation giving rise to the ambient toric variety.
Examples:
We construct a Calabi-Yau and check that the triangulation that this function returns is the same as the one we used to construct it.
Invariants
¶
Invariants(invariant_type, charge2invariant, grading_vec=None, cutoff=None, calabiyau=None, basis=None)
A container for Gopakumar-Vafa (GV) or Gromov-Witten (GW) invariants.
Objects of this class are generally obtained with
CalabiYau.compute_gvs or
CalabiYau.compute_gws. They
store a map from curve charges to the corresponding invariants, along with
information about how they were computed.
Parameters:
-
invariant_type(str) –The type of invariants, either
"gv"or"gw". -
charge2invariant(dict[tuple[int, ...], int] | ArrayLike) –The invariants, either as a dictionary mapping charges to invariants (
"dok"format) or as a list of rows of the form[q_1, ..., q_n, invariant]("coo"format). -
grading_vec(ArrayLike | None, default:None) –The grading vector used in the computation, which defines the degree of a charge.
-
cutoff(int | None, default:None) –The maximum degree used in the computation, if any. All invariants of charges up to this degree are assumed to be included.
-
calabiyau(CalabiYau | None, default:None) –The Calabi-Yau that the invariants correspond to.
-
basis(ndarray | None, default:None) –A matrix used to change the basis of the charges, where each charge \(q\) is replaced by
basis @ q. The grading vector is not transformed.
Raises:
-
ValueError–If
invariant_typeis not"gv"or"gw".
Examples:
We compute the GV invariants of a Calabi-Yau hypersurface up to degree 2 and look at some of them.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> gvs = cy.compute_gvs(max_deg=2)
>>> gvs.size
5
>>> gvs.gv((1, -3))
3
>>> gvs.gv((5, 5)) is None # Not computed
True
Methods:
-
charges–Return the charges of the stored invariants.
-
cone–Return the cone generated by the charges of the stored invariants.
-
gv–Return the GV invariant for a specific charge.
-
gw–Return the GW invariant for a specific charge.
-
invariant–Return the invariant for a specific charge.
Attributes:
-
coo–Return the invariants in the "coo" (COOrdinate) format.
-
cutoff–Return the degree cutoff used in the computation.
-
dok–Return the invariants in the "dok" (Dictionary Of Keys) format.
-
grading_vec–Return a copy of the grading vector used in the computation.
-
gvs(list) –Return the GV invariants.
-
gws(list) –Return the GW invariants.
-
size–Return the number of stored invariants.
coo
property
¶
Return the invariants in the "coo" (COOrdinate) format.
Returns:
-
ndarray–An array with rows of the form
[q_1, ..., q_n, invariant].
cutoff
property
¶
Return the degree cutoff used in the computation.
Returns:
-
int | None–The degree cutoff, or
Noneif it is not known (e.g. if the invariants were computed withmin_pointsortarget_points).
dok
property
¶
grading_vec
property
¶
Return a copy of the grading vector used in the computation.
Returns:
-
ndarray | None–The grading vector, or
Noneif it is not known.
gvs
property
¶
gws
property
¶
size
property
¶
charges
¶
Return the charges of the stored invariants.
Parameters:
-
by_deg(bool, default:False) –Whether to group the charges by degree, as determined by the grading vector.
-
as_np_arr(bool, default:False) –Whether to return the charges as numpy arrays instead of tuples.
Returns:
-
list[tuple[int, ...]] | ndarray | dict–If
by_degis false, a list of charges (or a 2D array ifas_np_arris true), in the same order as the invariants. Ifby_degis true, a dictionary mapping each degree, in ascending order, to a set of charges (or a 2D array ifas_np_arris true).
Raises:
-
ValueError–If
by_degis true and the grading vector is not known.
Examples:
We compute some GV invariants and group their charges by degree.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> gvs = cy.compute_gvs(max_deg=2)
>>> {int(d): len(c) for d, c in gvs.charges(by_deg=True).items()}
{1: 2, 2: 3}
>>> gvs.charges(by_deg=True)[1] == {(0, 1), (1, -3)}
True
cone
¶
Return the cone generated by the charges of the stored invariants.
For GV invariants, this is the "GV cone", i.e. the cone generated by the charges of the computed invariants.
Returns:
-
Cone–The cone generated by the charges.
Examples:
We compute some GV invariants and find the cone generated by their charges.
gv
¶
Return the GV invariant for a specific charge.
This is the same as invariant,
but it returns None if the stored invariants are GW invariants.
Parameters:
-
charge(ArrayLike) –The charge of interest.
-
check_deg(bool, default:True) –Whether to return 0 for charges that are not stored but whose degree is not greater than the cutoff. This is only done if the cutoff and the grading vector are known.
Returns:
-
int | None–The GV invariant, or
Noneif it is not known.
gw
¶
Return the GW invariant for a specific charge.
This is the same as invariant,
but it returns None if the stored invariants are GV invariants.
Parameters:
-
charge(ArrayLike) –The charge of interest.
-
check_deg(bool, default:True) –Whether to return 0 for charges that are not stored but whose degree is not greater than the cutoff. This is only done if the cutoff and the grading vector are known.
Returns:
-
Fraction | None–The GW invariant, or
Noneif it is not known.
invariant
¶
Return the invariant for a specific charge.
Parameters:
-
charge(ArrayLike) –The charge of interest.
-
check_deg(bool, default:True) –Whether to return 0 for charges that are not stored but whose degree is not greater than the cutoff. This is only done if the cutoff and the grading vector are known.
Returns:
-
int | Fraction | None–The invariant. If the charge is not stored, 0 is returned if
check_degis true and the degree of the charge is not greater than the cutoff, andNoneotherwise.
Examples:
We compute some GV invariants and look them up.
>>> from cytools import Polytope
>>> p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-6,-9]])
>>> t = p.triangulate()
>>> cy = t.get_cy()
>>> gvs = cy.compute_gvs(max_deg=2)
>>> gvs.invariant((0, 1))
540
>>> gvs.invariant((2, -7)) # Not stored, but degree 1 <= 2
0
>>> gvs.invariant((2, -5)) is None # Not stored, and degree 3 > 2
True