コード例 #1
0
"""
Example showing how to set up a semi-discretization and advect it.
"""

# Import libraries
##################
from nodepy import semidisc
from nodepy import *
import matplotlib.pyplot as pl

# Create spatial operator L (i.e. u' = L u)
###########################################
upwind = semidisc.load_semidisc('upwind advection')

# Create time marching
######################
rk4 = rk.loadRKM('RK44')

# Solve the problem
###################
t, y = rk4(upwind)

# Plot the soution
##################
pl.plot(upwind.xExact, upwind.uExactInit, label='Initial condition')
pl.plot(upwind.xExact, upwind.uExact, label='Exact solution')

pl.plot(upwind.xCenter, y[-1], label='Upwind solution')
pl.title('1D linear advection equation')
pl.xlabel('x')
pl.ylabel('u')
コード例 #2
0
ファイル: advectionSD.py プロジェクト: albertabone/nodepy
Example showing how to set up a semi-discretization with the spectral difference method and advect it.
"""

# Import libraries
##################
from nodepy import semidisc
from nodepy import *

import numpy as np
import matplotlib.pyplot as pl


# Create spatial operator L (i.e. u' = L u)
###########################################
orderAcc = 1
spectralDifference = semidisc.load_semidisc('spectral difference advection',order=orderAcc)


# Create time marching
######################
rk4=rk.loadRKM('RK44')


# Solve the problem
###################
t,y=rk4(spectralDifference)


# Plot the soution
##################
pl.plot(spectralDifference.xExact,spectralDifference.uExact,label = 'Exact solution')
コード例 #3
0
"""
Example showing how to set up a semi-discretization with the spectral difference method and advect it.
"""

# Import libraries
##################
from nodepy import semidisc
from nodepy import *

import numpy as np
import matplotlib.pyplot as pl

# Create spatial operator L (i.e. u' = L u)
###########################################
orderAcc = 1
spectralDifference = semidisc.load_semidisc('spectral difference advection',
                                            order=orderAcc)

# Create time marching
######################
rk4 = rk.loadRKM('RK44')

# Solve the problem
###################
t, y = rk4(spectralDifference)

# Plot the soution
##################
pl.plot(spectralDifference.xExact,
        spectralDifference.uExact,
        label='Exact solution')
pl.plot(spectralDifference.xExact,
コード例 #4
0
ファイル: advectionUPWIND.py プロジェクト: albertabone/nodepy
"""
Example showing how to set up a semi-discretization and advect it.
"""

# Import libraries
##################
from nodepy import semidisc
from nodepy import *
import matplotlib.pyplot as pl


# Create spatial operator L (i.e. u' = L u)
###########################################
upwind = semidisc.load_semidisc('upwind advection')


# Create time marching
######################
rk4=rk.loadRKM('RK44')


# Solve the problem
###################
t,y=rk4(upwind)


# Plot the soution
##################
pl.plot(upwind.xExact,upwind.uExactInit,label = 'Initial condition')
pl.plot(upwind.xExact,upwind.uExact,label = 'Exact solution')