Get started with QUICK-PDE
See the API reference
Qiskit Functions are an experimental feature available to IBM Quantum® Premium Plan, Flex Plan, and On-Prem (via IBM Quantum Platform API) Plan users. They are in preview release status and subject to change.
For an overview of this function, see the QUICK-PDE documentation home.
Set up
Fill out the form to request access to the QUICK-PDE function. Then, assuming you've already saved your account to your local environment, select the function as follows:
from qiskit_ibm_catalog import QiskitFunctionsCatalog
catalog = QiskitFunctionsCatalog(
channel="ibm_cloud / ibm_quantum_platform",
instance="USER_CRN / HGP",
token="USER_API_KEY / IQP_API_TOKEN",
)
catalog = QiskitFunctionsCatalog(channel="ibm_quantum_platform")
# Verify that you have access to the function
catalog.list()quick = catalog.load("colibritd/quick-pde")Examples
To get started, try one of the following examples:
Inviscid Burgers' equation (CFD)
For Burgers' equation, when initial conditions are set to , the results are as follows:
# launch the simulation with initial conditions u(0,x) = a*x + b
job = quick.run(
use_case="CFD_BURGER", physical_parameters={"a": 1.0, "b": 0.0}
)Check your Qiskit Function workload's status or return results as follows:
# Print the ID so you can use it later, if necessary
print(job.job_id)
print(job.status())
solution = job.result()import numpy as np
import matplotlib.pyplot as plt
def plot_result_3d(result):
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
t, x = np.meshgrid(result["samples"]["t"], result["samples"]["x"])
ax.plot_surface(
t,
x,
result["functions"]["u"],
edgecolor="royalblue",
lw=0.25,
rstride=26,
cstride=26,
alpha=0.3,
)
ax.scatter(t, x, result["functions"]["u"], marker=".")
ax.set(xlabel="t", ylabel="x", zlabel="u(t,x)")
plt.show()
# Call
plot_result_3d(solution)Pressureless Euler's equation (CFD)
For Euler's equation, when initial conditions are set to and , for a given (here, ) and , the results are as follows:
# Launches the solving for an arbitrary mu
job = quick.run(use_case="CFD_EULER", physical_parameters={"mu": 0.1})
solution = job.result()
# Colorplot function
def plot_result_2d(result):
fig, axes = plt.subplots(1, 2, figsize=(14, 5))
configs = {
"g": {"cmap": "viridis", "title": "g(t, x)"},
"u": {"cmap": "plasma", "title": "u(t, x)"},
}
t = result["samples"]["t"]
x = result["samples"]["x"]
for ax, (field, cfg) in zip(axes, configs.items()):
v = result["functions"][field]
im = ax.contourf(t, x, v, levels=50, cmap=cfg["cmap"])
fig.colorbar(im, ax=ax, label=cfg["title"])
ax.set_xlabel("t")
ax.set_ylabel("x")
ax.set_title(cfg["title"], fontsize=13, fontweight="bold")
plt.tight_layout()
plt.show()
plot_result_2d(solution)Material deformation
The material deformation use case requires the physical parameters of your material and the applied force, as follows:
# Select the properties of your material
job = quick.run(
use_case="MD",
physical_parameters={
"t": 12.0,
"K": 100.0,
"n": 4.0,
"b": 10.0,
"epsilon_0": 0.1,
"sigma_0": 5.0,
},
)
# Plot the result
solution = job.result()
_ = plt.figure()
stress_plot = plt.subplot(211)
plt.plot(solution["samples"]["x"], solution["functions"]["u"])
strain_plot = plt.subplot(212)
plt.plot(solution["samples"]["x"], solution["functions"]["sigma"])
plt.show()The following is an example of how to get the value of the function for a specific set of coordinates:
# u(t=0.2, x=0.7) == 2
assert solution["samples"]["t"][1] == 0.2
assert solution["samples"]["x"][2] == 0.7
assert solution["functions"]["u"][1, 2] == 2Fetch error messages
If your workload status is ERROR, use job.error_message() to fetch the error message to help debug, as follows:
job = quick.run(use_case="MD", physical_params={})
print(job.error_message())
# A wrapper can also be used for a more human readable version
def pprint_error(job):
print("".join(eval(job.error_message())["error"]))
print("___")
pprint_error(job)