# CalabiYau Class

This class handles various computations relating to the Calabi-Yau manifold itself. It can be used to compute intersection numbers, the toric Mori and Kähler cones that can be inferred from the ambient variety, among other things.

Generally, objects of this class should not be constructed directly by the
end user. Instead, they should be created by the
`get_cy`

function of the
`ToricVariety`

class or the
`get_cy`

function of the
`Triangulation`

class.

This package is focused on computations on Calabi-Yau 3-fold hypersurfaces, but there is experimental support for Calabi-Yaus of other dimensions and complete intersection. See experimental features for more details.

## Constructor

`cytools.calabiyau.CalabiYau`

**Description:**
Constructs a `CalabiYau`

object. This is handled by the hidden
`__init__`

function.

**Arguments:**

`toric_var`

*(ToricVariety)*: The ambient toric variety of the Calabi-Yau.`nef_partition`

*(list, optional)*: A list of tuples of indices specifying a nef-partition of the polytope, which correspondingly defines a complete intersection Calabi-Yau.

**Example**

We construct a Calabi-Yau from an fine, regular, star triangulation of a
polytope. Since this class is not intended to by initialized by the end
user, we create it via the
`get_cy`

function of the
`Triangulation`

class. 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 in a 4-dimensional toric variety

## Functions

`ambient_dim`

**Description:**
Returns the complex dimension of the ambient toric variety.

**Arguments:**
None.

**Returns:**
*(int)* The complex dimension of the ambient toric variety.

**Example**

We construct a Calabi-Yau and find the dimension of its ambient variety.

`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()

cy = t.get_cy()

cy.ambient_dim()

# 4

`ambient_variety`

**Description:**
Returns the ambient toric variety.

**Arguments:**
None.

**Returns:**
*(ToricVariety)* The ambient toric variety.

**Example**

We construct a Calabi-Yau hypersurface in a toric variety and check that this function returns the ambient variety.

`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()

v = t.get_toric_variety()

cy = v.get_cy()

cy.ambient_variety() is v

# True

`chi`

**Description:**
Computes the Euler characteristic of the Calabi-Yau.

Only Calabi-Yaus hypersurfaces of dimension 2-4 are currently supported. Hodge numbers of CICYs are computed with PALP.

**Arguments:**
None.

**Returns:**
*(int)* The Euler characteristic of the Calabi-Yau manifold.

**Example**

We construct a Calabi-Yau hypersurface and compute its Euler characteristic.

`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.h31()

# -540

`clear_cache`

**Description:**
Clears the cached results of any previous computation.

**Arguments:**

`recursive`

*(bool, optional, default=True)*: 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, optional, default=False)*: Only clears the cache of computations that depend on a choice of basis.

**Returns:**
Nothing.

**Example**

We construct a CY hypersurface, compute its toric Mori cone, clear the cache and then compute it again.

`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_AA`

**Description:**
Computes the matrix $\kappa_{ijk}t^k$ at a location in the Kähler cone.

This function only supports Calabi-Yau 3-folds.

**Arguments:**

`tloc`

*(array_like)*: A vector specifying a location in the Kähler cone.

**Returns:**
*(numpy.ndarray)* The matrix $\kappa_{ijk}t^k$ at the specified
location.

**Example**

We construct a Calabi-Yau hypersurface and compute this matrix at the tip of the stretched Kähler cone.

`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_AA(tip)

# array([[ 1., 1.],

# [ 1., -3.]])

`compute_Kinv`

**Description:**
Computes the inverse Kähler metric at a location in the Kähler cone.

This function only supports Calabi-Yau 3-folds.

**Arguments:**

`tloc`

*(array_like)*: A vector specifying a location in the Kähler cone.

**Returns:**
*(numpy.ndarray)* The inverse Kähler metric at the specified location.

**Example**

We construct a Calabi-Yau hypersurface and compute the inverse Kähler metric at the tip of the stretched Kähler cone.

`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_Kinv(tip)

# array([[11. , -9. ],

# [-9. , 42.99999998]])

`compute_curve_volumes`

**Description:**
Computes the volume of the curves corresponding to (not necessarily
minimal) generators of the Mori cone inferred from toric geometry (i.e.
the cone obtained with the `toric_mori_cone`

function).

**Arguments:**

`tloc`

*(array_like)*: A vector specifying a location in the Kähler cone.`only_extremal`

*(bool, optional, default=False)*: Use only the extremal rays of the Mori cone.

**Returns:**
*(numpy.ndarray)* The list of volumes of the curves.

**Example**

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.

`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([0.99997511, 3.99992091, 0.99998193])

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`

**Description:**
Computes the volume of the Calabi-Yau at a location in the Kähler cone.

**Arguments:**

`tloc`

*(array_like)*: A vector specifying a location in the Kähler cone.

**Returns:**
*(float)* The volume of the Calabi-Yau at the specified location.

**Example**

We construct a Calabi-Yau hypersurface and find its volume at the tip of the stretched Kähler cone.

`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_cy_volume(tip)

# 3.4999999988856496

`compute_divisor_volumes`

**Description:**
Computes the volume of the basis divisors at a location in the Kähler
cone.

**Arguments:**

`tloc`

*(array_like)*: A vector specifying a location in the Kähler cone.`in_basis`

*(bool, optional, default=False)*: When set to True, the volumes of the current basis of divisors are computed. Otherwise, the volumes of all prime toric divisors are computed.

**Returns:**
*(numpy.ndarray)* The list of volumes of the prime toric divisors or of
the basis divisors at the specified location.

**Example**

We construct a Calabi-Yau hypersurface and find the volumes of the prime toric divisors at the tip of the stretched Kähler cone.

`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 , 23.99999999, 16. , 2.5 , 2.5 ,

# 0.5 ])

`curve_basis`

**Description:**
Returns the current basis of curves of the Calabi-Yau.

**Arguments:**

`include_origin`

*(bool, optional, default=True)*: Whether to include the origin in the indexing of the vector, or in the basis matrix.`as_matrix`

*(bool, optional, default=False)*: Indicates whether to return the basis as a matrix intead of a list of indices of prime toric divisors. Note that if a matrix basis was specified, then it will always be returned as a matrix.

**Returns:**
*(numpy.ndarray)* A list of column indices that form a basis. If a more
generic basis has been specified with the
`set_divisor_basis`

or
`set_curve_basis`

functions then it returns a
matrix where the rows are the basis elements specified as a linear
combination of the canonical divisor and the prime toric divisors.

**Example**

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.

`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([1, 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]])

`dim`

**Description:**
Returns the complex dimension of the Calabi-Yau hypersurface.

**Arguments:**
None.

**Returns:**
*(int)* The complex dimension of the Calabi-Yau hypersurface.

**Example**

We construct a Calabi-Yau and find its dimension.

`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()

cy = t.get_cy()

cy.dim()

# 3

`divisor_basis`

**Description:**
Returns the current basis of divisors of the Calabi-Yau.

**Arguments:**

`include_origin`

*(bool, optional, default=True)*: Whether to include the origin in the indexing of the vector, or in the basis matrix.`as_matrix`

*(bool, optional, default=False)*: Indicates whether to return the basis as a matrix intead of a list of indices of prime toric divisors. Note that if a matrix basis was specified, then it will always be returned as a matrix.

**Returns:**
*(numpy.ndarray)* A list of column indices that form a basis. If a more
generic basis has been specified with the
`set_divisor_basis`

or
`set_curve_basis`

functions then it returns a
matrix where the rows are the basis elements specified as a linear
combination of the canonical divisor and the prime toric divisors.

**Example**

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.

`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([1, 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`

**Description:**
Computes the GLSM charge matrix of the theory.

**Arguments:**

`include_origin`

*(bool, optional, default=True)*: Indicates whether to use the origin in the calculation. This corresponds to the inclusion of the canonical divisor.

**Returns:**
*(numpy.ndarray)* The GLSM charge matrix.

**Example**

We construct a Calabi-Yau hypersurface and compute its GLSM charge matrix.

`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_charge_matrix()

# array([[-18, 1, 9, 6, 1, 1, 0],

# [ -6, 0, 3, 2, 0, 0, 1]])

`glsm_linear_relations`

**Description:**
Computes the linear relations of the GLSM charge matrix.

**Arguments:**

`include_origin`

*(bool, optional, default=True)*: Indicates whether to use the origin in the calculation. This corresponds to the inclusion of the canonical divisor.

**Returns:**
*(numpy.ndarray)* A matrix of linear relations of the columns of the
GLSM charge matrix.

**Example**

We construct a Calabi-Yau hypersurface and compute the GLSM linear relations.

`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, 1, 1, 1, 1, 1, 1],

# [ 0, 9, -1, 0, 0, 0, 3],

# [ 0, 6, 0, -1, 0, 0, 2],

# [ 0, 1, 0, 0, -1, 0, 0],

# [ 0, 1, 0, 0, 0, -1, 0]])

`h11`

**Description:**
Returns the Hodge number $h^{1,1}$ of the Calabi-Yau.

Only Calabi-Yaus hypersurfaces of dimension 2-4 are currently supported. Hodge numbers of CICYs are computed with PALP.

**Arguments:**
None.

**Returns:**
*(int)* The Hodge number $h^{1,1}$ of Calabi-Yau manifold.

**Example**

We construct a Calabi-Yau hypersurface and compute its $h^{1,1}$.

`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.h11()

# 2

`h12`

**Description:**
Returns the Hodge number $h^{1,2}$ of the Calabi-Yau.

Only Calabi-Yaus hypersurfaces of dimension 2-4 are currently supported. Hodge numbers of CICYs are computed with PALP.

**Arguments:**
None.

**Returns:**
*(int)* The Hodge number $h^{1,2}$ of Calabi-Yau manifold.

**Aliases:**
`h21`

.

**Example**

We construct a Calabi-Yau hypersurface and compute its $h^{1,2}$.

`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.h12()

# 272

`h13`

**Description:**
Returns the Hodge number $h^{1,3}$ of the Calabi-Yau.

**Arguments:**
None.

**Returns:**
*(int)* The Hodge number $h^{1,3}$ of Calabi-Yau manifold.

**Aliases:**
`h31`

.

**Example**

We construct a Calabi-Yau hypersurface and compute its $h^{1,3}$.

`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.h13()

# 0

`h22`

**Description:**
Returns the Hodge number $h^{2,2}$ of the Calabi-Yau.

**Arguments:**
None.

**Returns:**
*(int)* The Hodge number $h^{2,2}$ of Calabi-Yau manifold.

**Example**

We construct a Calabi-Yau hypersurface and compute its $h^{2,2}$.

`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.h22()

# 0

`hpq`

**Description:**
Returns the Hodge number $h^{p,q}$ of the Calabi-Yau.

- This function always computes Hodge numbers from scratch, unless
they were computed with PALP. The functions
`h11`

,`h21`

,`h12`

,`h13`

, and`h22`

cache the results so they offer improved performance.

**Arguments:**

`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 arising Calabi-Yau manifold.

**Example**

We construct a Calabi-Yau and check some of its Hodge numbers.

`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.hpq(0,0)

# 1

cy.hpq(0,1)

# 0

cy.hpq(1,1)

# 2

cy.hpq(1,2)

# 272

`intersection_numbers`

**Description:**
Returns the intersection numbers of the Calabi-Yau manifold.

The intersection numbers are computed as integers when it is smooth and using a subset of prime toric divisors as a basis. Otherwise, they are computed as floating-point numbers. There is the option to turn them into rationals. 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}$.

**Arguments:**

`in_basis`

*(bool, optional, default=False)*: Return the intersection numbers in the current basis of divisors.`format`

*(str, optional, default="dok")*: The output format of the intersection numbers. The options are "dok", "coo", and "dense". When set to "dok" (Dictionary Of Keys), it returns a dictionary where the keys are divisor indices in ascending order and the corresponding value is their intersection number. When set to "coo" (COOrdinate format), it returns a numpy array in the format [[a,b,...,c,K_ab...c],...], i.e. all but the last entry of each row correspond to divisor indices in ascending order, with the last entry of the row being their intersection number. Lastly, when set to "dense", it returns the full dense array of intersection numbers.`zero_as_anticanonical`

*(bool, optional, default=False)*: Treat the zeroth index as corresponding to the anticanonical divisor instead of the canonical divisor.`backend`

*(str, optional, 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, optional, default=True)*: Whether to explicitly check the solution to the linear system.`backend_error_tol`

*(float, optional, default=1e-3)*: Error tolerance for the solution of the linear system.`round_to_zero_treshold`

*(float, optional, default=1e-3)*: Intersection numbers with magnitude smaller than this treshold are rounded to zero.`round_to_integer_error_tol`

*(float, optional, default=5e-2)*: All intersection numbers of the Calabi-Yau hypersurface must be integers up to errors less than this value, when the CY is smooth.`verbose`

*(int, optional, default=0)*: The verbosity level.- verbose = 0: Do not print anything.
- verbose = 1: Print linear backend warnings.

`exact_arithmetic`

*(bool, optional, default=False)*: Converts the intersection numbers into exact rational fractions.

Returns:
*(dict or numpy.array)* When `format`

is set to "dok" (Dictionary Of
Keys), it returns a dictionary where the keys are divisor indices in
ascending order and the corresponding value is their intersection
number. When `format`

is set to "coo" (COOrdinate format), it returns
a numpy array in the format [[a,b,...,c,K_ab...c],...], i.e. all but
the last entry of each row correspond to divisor indices in ascending
order, with the last entry of the row being their intersection number.
Lastly, when set to "dense", it returns the full dense array of
intersection numbers.

**Example**

We construct a toric variety and compute its intersection numbers We
demonstrate the usage of the `in_basis`

flag and the different
available output formats.

`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()

# By default this function computes the intersection numbers of the canonical and prime toric divisors

intnum_nobasis = cy.intersection_numbers()

# Let's print the output and see how to interpret it

print(intnum_nobasis)

# {(1, 2, 3): 18, (2, 3, 4): 18, (1, 3, 4): 2, (1, 2, 4): 3, (1, 2, 5): 3, (2, 3, 5): 18, [the output is too long so we truncate it]

# The above output means that the intersection number of divisors 1, 2, 3 is 18, and so on

# Let us now compute the intersection numbers in a given basis of divisors

# First, let's check the current basis of divisors

cy.divisor_basis()

# array([1, 6])

# Now, setting in_basis=True we only compute the intersection numbers of divisors 1 and 6

intnum_basis = cy.intersection_numbers(in_basis=True)

# Let's print the output and see how to interpret it

print(intnum_basis)

# {(0, 0, 1): 1, (0, 1, 1): -3, (1, 1, 1): 9}

# Here, the indices correspond to indices of the basis divisors

# So the intersection of 1, 1, 6 is 1, and so on

# Now, let's look at the different output formats. The default one is the "dok" (Dictionary Of Keys) format shown above

# There is also the "coo" (COOrdinate format)

print(cy.intersection_numbers(in_basis=True, format="coo"))

# [[ 0 0 1 1]

# [ 0 1 1 -3]

# [ 1 1 1 9]]

# In this format, all but the last entry of each row are the indices and the last entry of the row is the intersection number

# Lastrly, there is the "dense" format where it outputs the full dense array

print(cy.intersection_numbers(in_basis=True, format="dense"))

# [[[ 0 1]

# [ 1 -3]]

#

# [[ 1 -3]

# [-3 9]]]

`is_smooth`

**Description:**
Returns True if the Calabi-Yau is smooth.

**Arguments:**
None.

**Returns:**
*(bool)* The truth value of the CY being smooth.

**Example**

We construct a Calabi-Yau hypersurface and check if it is smooth.

`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.is_smooth()

# True

`is_trivially_equivalent`

**Description:**
Checks if the Calabi-Yaus are trivially equivalent by checking if the
restrictions of the triangulations to codimension-2 faces are the same.
Polytope automorphisms are also taken into account. This function is
only implemented for CY hypersurfaces.

This function only provides a fairly trivial equivalence check. When this function returns False, there is still the possibility of the Calabi-Yaus being equivalent, but is only made evident with a change of basis. The full equivalence check is generically very difficult, so it is not implemented.

**Arguments:**

`other`

(CalabiYau): The other CY that is being compared.

**Returns:**
(boolean) The truth value of the CYs being trivially equivalent.

**Example**

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 basis transformation that relates them.

`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()

print(cy0.is_trivially_equivalent(cy1))

# False

cys_not_triv_eq = {t.get_cy() for t in triangs} # Not trivially equivalent, but not necessarily inequivalent

print(len(triangs),len(cys_not_triv_eq)) # We see that many CYs from these triangulations can be trivially equated

# 102 5

`polytope`

**Description:**
Returns the polytope whose triangulation gives rise to the ambient
toric variety.

**Arguments:**
None.

**Returns:**
*(Polytope)* The polytope whose triangulation gives rise to the ambient
toric variety.

**Example**

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.

`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()

cy = t.get_cy()

cy.polytope() is p

# True

`prime_toric_divisors`

**Description:**
Returns the list of inherited prime toric divisors. Due to the sorting
of points in the polytope class, this list is trivial for
hypersurfaces, but may be non-trivial for CICYs. The indices in the
returned tuple correspond to indices of the corresponding points of the
polytope (i.e. if $n$ is in the tuple, then the $n$th point in
`p.points()`

is a prime toric divisor that intersects the CY).

**Arguments:**
None

**Returns:**
*(tuple)* A list of indices indicating the points in the polytope whose
corresponding prime toric divisor intersects the CY.

**Example**

We construct a Calabi-Yau hypersurface and find the list of prime toric divisors.

`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.prime_toric_divisors()

# (1, 2, 3, 4, 5, 6)

`second_chern_class`

**Description:**
Computes the second Chern class of the CY hypersurface. Returns the
integral of the second Chern class over the prime effective divisors.

This function currently only supports CY 3-folds.

**Arguments:**

`in_basis`

*(bool, optional, default=False)*: Only return the integrals over a basis of divisors.`include_origin`

*(bool, optional, default=True)*: Include the origin in the vector, which corresponds to the canonical divisor.

**Returns:**
*(numpy.ndarray)* A vector containing the integrals.

**Example**

We construct a Calabi-Yau hypersurface and compute its second Chern class.

`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.second_chern_class()

# array([-612, 36, 306, 204, 36, 36, -6])

`set_curve_basis`

**Description:**
Specifies a basis of curves of the Calabi-Yau, which in turn
induces a basis of divisors. This can be done with a vector specifying
the indices of the standard basis of the lattice dual to the lattice of
prime toric divisors. Note that this case is equivalent to using the
same vector in the `set_divisor_basis`

function.

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.

**Arguments:**

`basis`

*(array_like)*: Vector or matrix specifying a basis. When a vector is used, the entries will be taken as indices of the standard basis of the dual to the lattice of prime toric divisors. When a matrix is used, the rows are taken as linear combinations of the aforementioned elements.`include_origin`

*(bool, optional, default=True)*: Whether to interpret the indexing specified by the input vector as including the origin.

**Returns:**
Nothing.

**Example**

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.

`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([1, 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 in this way, the function behaves
exactly the same as `set_divisor_basis`

. For
a more advanced example involving generic bases these two functions
differ. An example can be found in the
experimental features section.

`set_divisor_basis`

**Description:**
Specifies a basis of divisors of the Calabi-Yau. This can
be done with a vector specifying the indices of the prime toric
divisors.

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.

**Arguments:**

`basis`

*(array_like)*: Vector or matrix specifying a basis. When a vector is used, the entries will be taken as the indices of points of the polytope or prime divisors of the toric variety. When a matrix is used, the rows are taken as linear combinations of the aforementioned divisors.`include_origin`

*(bool, optional, default=True)*: Whether to interpret the indexing specified by the input vector as including the origin.

**Returns:**
Nothing.

**Example**

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.

`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([1, 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 for more generic basis choices can be found in the experimental features section.

`toric_effective_cone`

**Description:**
Returns the effective cone inferred from toric geometry.

**Arguments:**
None.

**Returns:**
*(Cone)* The toric effective cone.

**Example**

We construct a Calabi-Yau hypersurface and find its toric effective cone.

`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_effective_cone()

# A 2-dimensional rational polyhedral cone in RR^2 generated by 6 rays

`toric_kahler_cone`

**Description:**
Returns the Kähler cone inferred from toric geometry in the current
basis of divisors.

**Arguments:**
None.

**Returns:**
*(Cone)* The Kähler cone inferred from toric geometry.

**Example**

We construct a Calabi-Yau hypersurface and find its Kähler cone.

`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_kahler_cone()

# A rational polyhedral cone in RR^2 defined by 3 hyperplanes normals

`toric_mori_cone`

**Description:**
Returns the Mori cone inferred from toric geometry.

**Arguments:**

`in_basis`

*(bool, optional, default=False)*: Use the current basis of curves, which is dual to what the basis returned by the`divisor_basis`

function.`include_origin`

*(bool, optional, default=True)*: Includes the origin of the polytope in the computation, which corresponds to the canonical divisor.`from_intersection_numbers`

*(bool, optional, default=False)*: Compute the rays of the Mori cone using the intersection numbers of the variety. This can be faster if they are already computed. The set of rays may be different, but they define the same cone.

**Returns:**
*(Cone)* The Mori cone inferred from toric geometry.

**Example**

We construct a Calabi-Yau hypersurface and find its Mori cone in an $h^{1,1}+d+1$ dimensional lattice (i.e. without a particular choice of basis) and in an $h^{1,1}$ dimensional lattice (i.e. after picking a basis of curves).

`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) # It uses the dual basis of curves to the current divisor basis

# A 2-dimensional rational polyhedral cone in RR^2 generated by 3 rays

`triangulation`

**Description:**
Returns the triangulation giving rise to the ambient toric variety.

**Arguments:**
None.

**Returns:**
*(Triangulation)* The triangulation giving rise to the ambient toric
variety.

**Example**

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.

`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()

cy = t.get_cy()

cy.triangulation() is t

# True

## Hidden Functions

`__eq__`

**Description:**
Implements comparison of Calabi-Yaus with ==.

This function provides only a fairly trivial comparison using the
`is_trivially_equivalent`

function. It is
not recommended to compare CYs with ==, and a warning will be
printed every time it evaluates to False. This is only implemented so
that sets and dictionaries of CYs can be created.
The `is_trivially_equivalent`

function
should be used to avoid confusion.

**Arguments:**

`other`

*(CalabiYau)*: The other CY that is being compared.

**Returns:**
*(bool)* The truth value of the CYs being equal.

**Example**

We construct two Calabi-Yaus and compare them. We use the
`is_trivially_equivalent`

instead of
this function, since it is recommended to avoid confusion.

`p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-1,-1]])`

t1 = p.triangulate(backend="qhull")

cy1 = t1.get_cy()

t2 = p.triangulate(backend="topcom")

cy2 = t2.get_cy()

cy1.is_trivially_equivalent(cy2)

# True

`__hash__`

**Description:**
Implements the ability to obtain hash values from Calabi-Yaus.

**Arguments:**
None.

**Returns:**
*(int)* The hash value of the CY.

**Example**

We compute the hash value of a Calabi-Yau. Also, we construct a set and a dictionary with a Calabi-Yau, which make use of the hash function.

`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()

cy = t.get_cy()

h = hash(cy) # Obtain hash value

d = {cy: 1} # Create dictionary with Calabi-Yau keys

s = {cy} # Create a set of Calabi-Yaus

`__init__`

**Description:**
Initializes a `CalabiYau`

object.

**Arguments:**

`toric_var`

*(ToricVariety)*: The ambient toric variety of the Calabi-Yau.`nef_partition`

*(list, optional)*: A list of tuples of indices specifying a nef-partition of the polytope, which correspondingly defines a complete intersection Calabi-Yau.

**Returns:**
Nothing.

**Example**

This is the function that is called when creating a new
`ToricVariety`

object. We construct a Calabi-Yau from an fine,
regular, star triangulation of a polytope. Since this class is not
intended to by initialized by the end user, we create it via the
`get_cy`

function of the
`Triangulation`

class. 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 in a 4-dimensional toric variety

`__ne__`

**Description:**
Implements comparison of Calabi-Yaus with !=.

This function provides only a fairly trivial comparison using the
`is_trivially_equivalent`

function. It is
not recommended to compare CYs with !=, and a warning will be
printed every time it evaluates to False. This is only implemented so
that sets and dictionaries of CYs can be created.
The `is_trivially_equivalent`

function
should be used to avoid confusion.

**Arguments:**

`other`

*(Polytope)*: The other CY that is being compared.

**Returns:**
*(bool)* The truth value of the CYs being different.

**Example**

We construct two Calabi-Yaus and compare them. We use the
`is_trivially_equivalent`

instead of
this function, since it is recommended to avoid confusion.

`p = Polytope([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],[-1,-1,-1,-1]])`

t1 = p.triangulate(backend="qhull")

cy1 = t1.get_cy()

t2 = p.triangulate(backend="topcom")

cy2 = t2.get_cy()

cy1.is_trivially_equivalent(cy2)

# True

`__repr__`

**Description:**
Returns a string describing the Calabi-Yau manifold.

**Arguments:**
None.

**Returns:**
*(str)* A string describing the Calabi-Yau manifold.

**Example**

This function can be used to convert the Calabi-Yau to a string or to print information about the Calabi-Yau.

`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()

cy = t.get_cy()

cy_info = str(cy) # Converts to string

print(cy) # Prints Calabi-Yau info

# A Calabi-Yau 3-fold hypersurface with h11=1 and h21=101 in a 4-dimensional toric variety

`_compute_cicy_hodge_numbers`

**Description:**
Computes the Hodge numbers of a CICY using PALP. The results are stored
in a hidden dictionary.

This function should generally not be called by the user. Instead, it
is called by `hpq`

and other Hodge number functions when
necessary.

**Arguments:**

`only_from_cache`

*(bool, optional, default=False)*: Check if the Hodge numbers of the CICY were previously computed and are stored in the cache of the polytope object. Only if this flag is false and the Hodge numbers are not cached, then PALP is used to compute them.

**Returns:**
Nothing.

**Example**

This function is not intended to be directly used, but it is used in the following example. We construct a CICY and compute some of its Hodge numbers.

`p = Polytope([[1,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[-1,-1,-6,-9,0],[0,0,0,0,1],[0,0,0,0,-1]])`

nef_part = p.nef_partitions(compute_hodge_numbers=False)

t = p.triangulate(include_points_interior_to_facets=True)

cy = t.get_cy(nef_part[0])

cy.h11() # The function is called here since the Hodge numbers have not been computed

# 4

cy.h21() # It is not called here because the Hodge numbers are already cached

# 544