# Executing Multiple Workflows (Lattices)#

Execute multiple lattices from the same script.

In Covalent there is no reason you cannot dispatch multiple lattices from the same script. Each dispatch is tracked separately and generates a different result set.

You might run two lattices from the same script if, for instance, the lattices represent two different approaches to the same problem and you want to programmatically compare the result sets.

## Procedure#

1. Write the lattices:

[1]:

import covalent as ct

INF_LIMIT = 50

# Calculate e based on a formula
@ct.electron
def e_exp(x):
return (1 + 1/x) ** x

# Calculate e based on a series
@ct.electron
def e_ser(x):
e_est = 1
fact = 1
for i in range(1, x):
fact *= i
e_est += 1/fact
return e_est

@ct.lattice
def wf_exp(x):
return e_exp(x)

@ct.lattice
def wf_ser(x):
return e_ser(x)

1. Dispatch the lattices separately.

[2]:

wf_exp_id = ct.dispatch(wf_exp)(INF_LIMIT)
wf_ser_id = ct.dispatch(wf_ser)(INF_LIMIT)

1. Compare the results.

[3]:

r_exp = ct.get_result(wf_exp_id, wait=True)
r_ser = ct.get_result(wf_ser_id, wait=True)

print(r_exp.result)
print(r_ser.result)

2.691588029073608
2.7182818284590455


Looping

Executing a Lattice Multiple Times