<jupyter_start><jupyter_text>This notebook is used to define a noise model for benchmarking purposes.<jupyter_code>import numpy as np
import qutip as qt
import qsharp
from qsharp.experimental import enable_noisy_simulation, get_noise_model, set_noise_model
enable_noisy_simulation()
I, X, Y, Z = qt.qeye(2), qt.sigmax(), qt.sigmay(), qt.sigmaz()
sI, sX, sY, sZ = map(qt.to_super, [I, X, Y, Z])
def total_dephasing_channel():
    return (1 / 2) * sI + (1 / 2) * sZ
def dephasing_channel(p):
    return (1 - p) * sI + p * total_dephasing_channel()
dephasing_channel(0.1)
def total_depolarizing_channel():
    return (sI + sX + sY + sZ) / 4
def depolarizing_channel(p):
    return (1 - p) * sI + p * total_depolarizing_channel()
def finite_visibility_meas(visibility):
    return [
        qt.to_super(visibility * (I + sign * Z) / 2 + (1 - visibility) * I / 2)
        for sign in (+1, -1)
    ]
noise_model = get_noise_model()
noise_model['x'] = depolarizing_channel(0.1) * sX
noise_model['z'] = dephasing_channel(0.1) * sZ
noise_model['z_meas']['effects'] = finite_visibility_meas(0.95)
set_noise_model(noise_model)
qsharp.client._execute('%experimental.noise_model --save benchmark-noise-model.json')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13566206336311942, 'fraction_numerical': 0.017871649065800164, 'mean_word_length': 4.757009345794392, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '637248', 'license': 'MIT', 'n_tokens_mistral': 504, 'n_tokens_neox': 463, 'n_words': 110, 'path': 'src/Simulation/qdk_sim_rs/benches/data/noise-model-export.ipynb', 'repo_name': 'Bradben/qsharp-runtime', 'size': '1231'}