Commit 0f16832e authored by Murali's avatar Murali
Browse files

Minor edits

parent 06067492
Loading
Loading
Loading
Loading
+22 −34
Original line number Diff line number Diff line
@@ -96,18 +96,11 @@ def Hele_Shaw(doc_id, args):
    # for solving velocity, need to load pressure profile solved using HHL (if available)
    filename_pressure = input_vars['filename_pressure'].format(**input_vars)
    if var == 'velocity' and os.path.isfile(filename_pressure):
        # first find the corresponding pressure case
        file = open(f'{filename_pressure}', 'rb')
        data = pickle.load(file)
        file.close()
        filename_pressure = f"{filename_pressure[:-13]}_circ-fullresults_nq{data['NUM_QUBITS']}_backend-{data['args'].backend_method}_shots{data['args'].SHOTS}.pkl"
        # see if full data is available
        if os.path.isfile(filename_pressure):
        print('Using HHL solved pressure profile...')
        file = open(f'{filename_pressure}', 'rb')
        data = pickle.load(file)
        file.close()
            state_hhl = data['exact_solution_vector']
        state_hhl = data['counts_solution_vector']
        state_true_norm = data['classical_solution'].state
        # check if matrix was padded for non-2 power size
        nsys = nx*ny
@@ -129,8 +122,7 @@ def Hele_Shaw(doc_id, args):
    else:
        print('Using analytical pressure profile...')
    # make sure size of A & B is power of 2
    print(f'Determinant of resulting matrix: {np.linalg.det(A)}\nCondition # of resulting matrix: {np.linalg.cond(A)}')
    # contidion # ??
    print(f'Determinant of matrix: {np.linalg.det(A)}\nCondition # of matrix: {np.linalg.cond(A)}')
    A, B = check_size_pow2(A, B)
    A_herm, B_herm = check_matrix_herm(A, B)
    print(f'Reformatted A_herm:\n{A_herm}\nB_herm:\n{B_herm}')
@@ -188,11 +180,9 @@ def Cylinder_2D(doc_id, args):
    # print(f'norm_exact: {np.linalg.norm(phi_exact):1.3e}; norm_numerical: {np.linalg.norm(phi_mapped[np.isfinite(phi_mapped)]):1.3e}')

    # make sure size of A & B is power of 2 and Hermitian
    print(f'Determinant of resulting matrix: {np.linalg.det(A)}')
    # contidion # ??
    print(f'Determinant of matrix: {np.linalg.det(A)}\nCondition # of matrix: {np.linalg.cond(A)}')
    A, B = check_size_pow2(A, B)  
    A_herm, B_herm = check_matrix_herm(A, B)
    
    print(f'Reformatted A_herm:\n{A_herm}\nB_herm:\n{B_herm}')
    print(f'Determinant of resulting matrix: {np.linalg.det(A_herm)}\nCondition # of resulting matrix: {np.linalg.cond(A_herm)}')
    return A_herm, B_herm, input_vars
@@ -207,7 +197,6 @@ def check_size_pow2(A, B):
    # make sure nsys is power of 2
    nsys_nxtpower = next_power_of_2(nsys)
    if nsys_nxtpower-nsys > 0:
        print(f'Determinant of resulting matrix: {np.linalg.det(A)}')
        print(f'Size of A & B are not power of 2:\nNext 2 power of {nsys} = {nsys_nxtpower}\nValue to be padded = {nsys_nxtpower-nsys}')
        # Desired number of rows and columns for the resulting square matrix
        desired_size = nsys_nxtpower
@@ -239,7 +228,6 @@ def check_size_pow2(A, B):
        print(f'Padded B:\n{B_padded}')
        A = A_padded
        B = B_padded
        print(f'Determinant of resulting matrix: {np.linalg.det(A)}')
    return A, B

def check_matrix_herm(A, B):
+0 −1
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ def qc_circ(n_qubits_matrix, classical_solution, args, input_vars):
        save_data = {   'args'                      : args,
                        'input_vars'                : input_vars,
                        'counts'                    : counts,
                        'exact_vector'              : exact_vector,
                        'counts_ancilla'            : counts_ancilla,
                        'counts_vector'             : counts_vector,
                        'counts_solution_vector'    : counts_solution_vector,
+2 −2
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@ L: 1 # length of channel
D: 1                 # width/height of channel
mu: 1                # fluid viscosity
rho: 1               # fluid density
nx: 2          # number of grid points in the x (horizontal) direction
nx: 3          # number of grid points in the x (horizontal) direction
ny: 3          # number of grid points in the y (vertical/span-wise) direction
var: velocity   # which variable to solve for? pressure or velocity
savedir: models
fileprefix: 2DHS_HHL_fulldata
savefilename: "{savedir}/{fileprefix}_{var}_nx{nx}_ny{ny}"
filename_pressure: "{savedir}/{fileprefix}_pressure_nx{nx}_ny{ny}_metadata.pkl"
filename_pressure: "{savedir}/{fileprefix}_pressure_nx{nx}_ny{ny}_circ-fullresults_nqmatrix5_backend-statevector_shots1000.pkl"

---
# Case 2: Variables for potential flow over cylinder