From 2a1cae6976d4b7b57098abc83e3044b871debfc7 Mon Sep 17 00:00:00 2001 From: Victor Alves <50674829+victoraalves@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:15:54 -0400 Subject: [PATCH] started low dimensional mappings for joint polytopic regions. --- src/opyrability.py | 61 +++++++++++++++++++++++++++++++++++++++++++++- tests/dma_mr.py | 21 ++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/opyrability.py b/src/opyrability.py index 7b7ae17..aee26b4 100644 --- a/src/opyrability.py +++ b/src/opyrability.py @@ -1465,7 +1465,66 @@ def AIS2AOS_map(model: Callable[...,Union[float,np.ndarray]], if plot is False: pass elif plot is True: - if input_map.shape[-1] == 2 and AOS.shape[-1] == 2: + + if input_map.shape[-1] == 1 and AOS.shape[-1] == 1: + + + input_plot = input_map.reshape(np.prod(input_map.shape[0:-1]), + input_map.shape[-1]) + + AOS_plot = AOS.reshape(np.prod(AOS.shape[0:-1]), AOS.shape[-1]) + + _, ax = plt.subplots(nrows=1,ncols=1, + constrained_layout=True) + + plt.rcParams['figure.facecolor'] = 'white' + ax.scatter(input_plot[:, 0], AOS_plot[:, 1], s=16, + c=np.sqrt(AOS_plot[:, 0]**2), + cmap=cmap, antialiased=True, + lw=lineweight, marker='s', + edgecolors=edgecolors) + + + elif input_map.shape[-1] == 2 and AOS.shape[-1] == 1: + + + input_plot = input_map.reshape(np.prod(input_map.shape[0:-1]), + input_map.shape[-1]) + + AOS_plot = AOS.reshape(np.prod(AOS.shape[0:-1]), AOS.shape[-1]) + + _, (ax1, ax2) = plt.subplots(nrows=1,ncols=2, + constrained_layout=True) + + plt.rcParams['figure.facecolor'] = 'white' + ax1.scatter(input_plot[:, 0], input_plot[:, 1], s=16, + c=np.sqrt(AOS_plot[:, 0]**2), + cmap=cmap, antialiased=True, + lw=lineweight, marker='s', + edgecolors=edgecolors) + + ax1.set_xlabel('$u_{1}$') + if (EDS_bound and EDS_resolution) is None: + ax1.set_title('$AIS_{u}$') + ax1.set_ylabel('$u_{2}$') + else: + ax1.set_title('$AIS_{u} \, and \, EDS_{d}$') + ax1.set_ylabel('$d_{1}$') + + + ax2.scatter(AOS_plot[:, 0], np.array([np.zeros(AOS_plot[:,0].size),]).T, s=16, + c=np.sqrt(AOS_plot[:, 0]**2), + cmap=cmap, antialiased=True, + lw=lineweight, marker='o', + edgecolors=edgecolors) + + # ax2.set_ylabel('$y_{2}$') + plt.xlabel('$y_{1}$') + plt.yticks([]) + + ax2.set_title('$AOS$') + + elif input_map.shape[-1] == 2 and AOS.shape[-1] == 2: input_plot = input_map.reshape(np.prod(input_map.shape[0:-1]), input_map.shape[-1]) diff --git a/tests/dma_mr.py b/tests/dma_mr.py index 2d0b288..256709c 100644 --- a/tests/dma_mr.py +++ b/tests/dma_mr.py @@ -159,6 +159,27 @@ def dma_mr_design(u): return jnp.array([F_C6H6, X_CH4]) + +def dma_mr_2x1(u): + + + L = u[0] + dt = u[1] + + # Initial conditions + y0 = jnp.hstack((Ft0, jnp.zeros(7))) + rtol, atol = 1e-10, 1e-10 + + z = jnp.linspace(0, L, 2000) + F = odeint(dma_mr_jax, y0, z, dt, rtol=rtol, atol=atol) + + + F_C6H6 = ((F[-1, 3] * 1000) * MM_B) + # X_CH4 = (100 * (Ft0 - F[-1, 0] - F[-1, 4]) / Ft0) + + return jnp.array([F_C6H6]) + + def dma_mr_mvs(u):