Beispiel #1
0
def test_shockwave_Ps():
    assert sw.Ps_ratio(1.) == 1.
    assert sw.Ps_ratio(1.1) == pytest.approx(1.245)
    assert sw.Ps_ratio(2.) == pytest.approx(4.5)
    assert sw.Ps_ratio(1., gamma=1.3) == 1.
    assert sw.Ps_ratio(1.1, gamma=1.3) == pytest.approx(1.2373913043478264)
    assert sw.Ps_ratio(2., gamma=1.3) == pytest.approx(4.391304347826088)
Beispiel #2
0
	def _rankinehugoniot_from_ushock(self, ushock):
		"""
			returns Rankine-Hugoniot state, given a shock velocity
		
			..warning:: this function is made private because there is no test about upstream/downstream consistency
			nor the right ushock range (greater than u+a or lesser than u-a
		"""
		loc_Mn    = (self.u-ushock)/self.asound()          # this Mach number is signed
		rho_ratio = sw.Rho_ratio(loc_Mn, self._gamma)
		return unsteady_state(self.rho * rho_ratio,
		             ushock + (self.u-ushock)/rho_ratio,
		             self.p * sw.Ps_ratio(loc_Mn, self._gamma),
	 	             gamma=self._gamma)
Beispiel #3
0
def test_Mn_Ps():
    assert sw.Ps_ratio(2.) == pytest.approx(4.5)
    assert sw.Mn_Ps_ratio(sw.Ps_ratio(3.)) == pytest.approx(3.)
Beispiel #4
0
def plot_theta_pressure(mach,
                        gamma=defg._gamma,
                        npts=100,
                        thet_init=0.,
                        p_init=1.,
                        curve='both',
                        devmax=False,
                        sonic=False,
                        color='k',
                        linestyle='-',
                        ax=plt,
                        **kwargs):
    """
    	Plot shock polar curve in deviation / pressure ratio axes

		Long comment
 
		:param mach:       upstream Mach number
        :param gamma:      specific heat ratio, default from aerokit.common.defaultgas
        :param npts:       number of computed points, curve accuracy
        :param thet_init:  upstream angle (shift the curve by this angle), default 0.
        :param p_init:     reference pressure (shift the curve by this ratio), default 1.
        :param curve:      choose which curve to plot (left, right or both)
		:return:     
 
 		:Example:

		.. seealso:: 
		.. note:: 
    """

    sig = np.linspace(deg.asin(1. / mach), 90., npts + 1)
    dev = sw.deflection_Mach_sigma(mach, sig, gamma)
    ps = p_init * sw.Ps_ratio(
        mach * deg.sin(sig),
        gamma)  # pressure ratio only depends on normal Mach number
    if curve in ['right', 'both']:
        ax.plot(thet_init + dev,
                ps,
                color=color,
                linestyle=linestyle,
                **kwargs)
    if curve in ['left', 'both']:
        ax.plot(thet_init - dev,
                ps,
                color=color,
                linestyle=linestyle,
                **kwargs)
    if devmax:
        thet = sw.dev_Max(mach, gamma=gamma)
        sig = sw.sigma_DevMax(mach, gamma=gamma)
        ps = sw.Ps_ratio(mach * deg.sin(sig), gamma=gamma)
        if curve in ['right', 'both']:
            ax.plot(thet_init + thet, p_init * ps, 'ro', alpha=0.9)
        if curve in ['left', 'both']:
            ax.plot(thet_init - thet, p_init * ps, 'ro', alpha=0.9)
    if sonic:
        thet = sw.dev_Sonic(mach, gamma=gamma)
        sig = sw.sigma_Sonic(mach, gamma=gamma)
        ps = sw.Ps_ratio(mach * deg.sin(sig), gamma=gamma)
        if curve in ['right', 'both']:
            ax.plot(thet_init + thet,
                    p_init * ps,
                    'ko',
                    markerfacecolor='white')
        if curve in ['left', 'both']:
            ax.plot(thet_init - thet,
                    p_init * ps,
                    'ko',
                    markerfacecolor='white')
Beispiel #5
0
fsol = solver.solve(finit, cfl, stop={"maxit": nit_super}, monitors=monitors)

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 4))
monitors["residual"]["output"].semilogplot_it(ax=ax1)
fsol[-1].plot('mach', style='-', axes=ax2)
fsol[-1].plot('ptot', style='-', axes=ax3)
finit.plot('mach', style='--', axes=ax2)
finit.plot('ptot', style='--', axes=ax3)
fig.show()

# if verbose: solver.show_perf()
res["init_residual"] = monitors["residual"]["output"]._value[-1]
res["init_M9"] = fsol[-1].phydata("mach")[-1]

# RESTART
bcR = {"type": bctype, "p": 1.1 * sw.Ps_ratio(Msup, gam)}
rhs = modeldisc.fvm(model, meshsim, muscl(vanleer), bcL=bcL, bcR=bcR)
solver = rk3ssp(meshsim, rhs)
try:
    fsol = solver.solve(fsol[-1],
                        cfl,
                        stop={"maxit": nit_tot},
                        monitors=monitors)
    solver.show_perf()
    res["simu_residual"] = monitors["residual"]["output"]._value[-1]
    res["simu_M9"] = fsol[-1].phydata("mach")[-1]
    # if verbose: print(res)
except Exception:
    res["simu_residual"] = 1.0e9
    res["simu_M9"] = 0.0