cape.pycart.pointSensor: Cart3D point sensors module¶
This module contains several classes for reading and averaging point
sensors. The database classes, DBPointSensorGroup and
DBPointSensor, are based on versions from the generic point
sensor module pointSensor, while the iterative history class
CasePointSensor is based off of the generic
databook.CaseData module.
Tracking the iterative history of a point sensor requires declaring a
point sensor in the Cart3D input.cntl file and requesting
information about it at regularly scheduled iterations.
At present, there is no support for extracting point sensors from a
surface solution file ("TriqPoint" data book type).
- See also:
pointSensorcape.pycart.inputCntldatabook
- class cape.pycart.pointsensor.CasePointSensor¶
Individual case point sensor history
- Call:
>>> P = CasePointSensor()
- Outputs:
- P:
pyCart.pointsensor.CasePointSensor Case point sensor
- P.mach:
float Mach number for this case; for calculating pressure coefficient
- P.nPoint:
int Number of point sensors
- P.nIter:
int Number of iterations recorded in point sensor history
- P.nd:
2|3 Number of dimensions
- P.iSteady:
int Maximum steady-state iteration number
- P.data:
numpy.ndarray(nPoint, nIter, 10 | 12) Data array
- P:
- Versions:
2015-12-01
@ddalle: First version
- AppendIteration(PS)¶
Add a single-iteration of point sensor data to the history
- Call:
>>> P.AppendIteration(PS)
- Inputs:
- P:
pyCart.pointsensor.CasePointSensor Iterative point sensor history
- PS:
pyCart.pointsensor.PointSensor Point sensor
- P:
- Versions:
2015-11-30
@ddalle: First version
- ExtractValue(c, k=None)¶
Extract the iterative history for one coefficient/state
The following states are available
"X": x-coordinate of point"Y": y-coordinate of point"Z": z-coordinate of point"dp": static pressure, \(p/p_\infty-1\)"rho": static density, \(\rho/\rho_\infty\)"U": x-component of velocity, \(u/a_\infty\)"V": y-component of velocity, \(v/a_\infty\)"W": z-component of velocity, \(w/a_\infty\)"P": static pressure, \(p/(\gamma p_\infty)\)"Cp": pressure coefficient, \(dp/(0.7*M_\infty^2\)"p": static pressure, \(p/p_\infty\)"T": Static temperature, \(T/T_\infty\)"M": Mach number
- Call:
>>> C = PS.ExtractValue(c, k=None)
- Inputs:
- Outputs:
- C:
np.ndarray Array of values for c at each sample
- C:
- Versions:
2015-12-07
@ddalle: First version
- GetPointSensorIndex(name)¶
Get the index of a point sensor by its name in
input.cntl- Call:
>>> k = P.GetPointSensorIndex(name)
- Inputs:
- P:
pyCart.pointsensor.CasePointSensor Iterative point sensor history
- name:
str Name of the sensor
- P:
- Outputs:
- k: :class;`int`
Index of nearest point in the sampled data
- Versions:
2105-12-04
@ddalle: First version
- GetStats(k, nStats=1, nLast=None)¶
Compute min, max, mean, and standard deviation of each quantity
This includes computing pressure coefficient. NaNs are reported as the standard deviation if nStats is 1 or 0. If the point sensor is two-dimensional, i.e. P.nd is 2, the W velocity is reported as 0.0.
- Call:
>>> s = P.GetStats(k, nStats=1, nLast=None)
- Inputs:
- Outputs:
- Versions:
2015-12-04
@ddalle: First version
- PlotState(c, pt, **kw)¶
Plot the iterative history of a state
- Call:
>>> h = P.PlotState(c, pt, n=None, nAvg=100, **kw)
- Inputs:
- P:
pyCart.databook.PointSensor Case component history class
- c:
str Name of coefficient to plot, e.g.
'Cp'- pt:
str|int Name or index of point sensor
- n:
int Only show the last n iterations
- nAvg:
int Use the last nAvg iterations to compute an average
- d:
float Delta in the coefficient to show expected range
- k:
float Multiple of iterative standard deviation to plot
- u:
float Multiple of sampling error standard deviation to plot
- eps:
float Fixed sampling error, default uses
SigmaMean()- nLast:
int Last iteration to use (defaults to last iteration available)
- nFirst:
int First iteration to plot
- FigWidth:
float Figure width
- FigHeight:
float Figure height
- LineOptions:
dict Dictionary of additional options for line plot
- StDevOptions:
dict Options passed to
pltfile.fill_between()for stdev plot- ErrPltOptions:
dict Options passed to
pltfile.fill_between()for uncertainty plot- DeltaOptions:
dict Options passed to
pltfile.plot()for reference range plot- MeanOptions:
dict Options passed to
pltfile.plot()for mean line- ShowMu:
bool Option to print value of mean
- ShowSigma:
bool Option to print value of standard deviation
- ShowEpsilon:
bool Option to print value of sampling error
- ShowDelta:
bool Option to print reference value
- P:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2015-12-07
@ddalle: First version
- ReadHist(fname='pointSensors.hist.dat')¶
Read point sensor iterative history file
- Call:
>>> P.ReadHist(fname='pointSensors.hist.dat')
- Inputs:
- fname:
str Name of point sensor history file
- fname:
- Versions:
2015-11-30
@ddalle: First version
- UpdateIterations()¶
Read any Cart3D point sensor output files and save them
- Call:
>>> P.UpdateIterations()
- Inputs:
- P:
pyCart.pointsensor.CasePointSensor Iterative point sensor history
- P:
- Versions:
2015-11-30
@ddalle: First version
- class cape.pycart.pointsensor.DBPointSensor(cntl, opts, pt, name=None, **kw)¶
Point sensor data book
- Call:
>>> DBP = DBPointSensor(x, opts, pt, name=None)
- Inputs:
- Outputs:
- DBP:
pyCart.pointsensor.DBPointSensor An individual point sensor data book
- DBP:
- Versions:
2015-12-04
@ddalle: Started
- class cape.pycart.pointsensor.DBPointSensorGroup(cntl, opts, name, **kw)¶
Point sensor group data book
- Call:
>>> DBPG = DBPointSensorGroup(x, opts, name)
- Inputs:
- x:
cape.runmatrix.RunMatrix RunMatrix/run matrix interface
- opts:
cape.options.Options Options interface
- name:
str|None Name of data book item (defaults to pt)
- pts:
list[str] |None List of points to read, by default all points in the group
- RootDir:
str|None Project root directory absolute path, default is PWD
- x:
- Outputs:
- DBPG:
pyCart.pointsensor.DBPointSensorGroup A point sensor group data book
- DBPG:
- Versions:
2015-12-04
@ddalle: First version
- cape.pycart.pointsensor.ImportPyPlot()¶
Import
matplotlib.pyplotif not loaded- Call:
>>> pyCart.databook.ImportPyPlot()
- Versions:
2014-12-27
@ddalle: First version
- class cape.pycart.pointsensor.PointSensor(fname='pointSensors.dat', data=None)¶
Class for individual point sensor
- Call:
>>> PS = PointSensor(fname="pointSensors.dat", data=None)
- Inputs:
- fname:
str Name of Cart3D output point sensors file
- data:
np.ndarray[float] Data array with either 9 (2-D) or 11 (3-D) columns
- fname:
- Outputs:
- PS:
pyCart.pointsensor.PointSensor Point sensor
- PS.data:
np.ndarray[float] Data array with either 9 (2-D) or 11 (3-D) columns
- PS.nd:
2|3 Number of dimensions of the data
- PS.nPoint:
int Number of points in the file
- PS.nIter:
int Number of iterations used to calculate the average
- PS:
- Versions:
2015-11-30
@ddalle: First version
- ExtractValue(c)¶
Extract the iterative history for one coefficient/state
The following states are available
"X": x-coordinate of point"Y": y-coordinate of point"Z": z-coordinate of point"dp": static pressure, \(p/p_\infty-1\)"rho": static density, \(\rho/\rho_\infty\)"U": x-component of velocity, \(u/a_\infty\)"V": y-component of velocity, \(v/a_\infty\)"W": z-component of velocity, \(w/a_\infty\)"P": static pressure, \(p/(\gamma p_\infty)\)"Cp": pressure coefficient, \(dp/(0.7*M_\infty^2\)"p": static pressure, \(p/p_\infty\)"T": Static temperature, \(T/T_\infty\)"M": Mach number
The values Z and W are not available for 2D data
- Call:
>>> C = PS.ExtractValue(c)
- Inputs:
- PS:
pyCart.pointsensor.PointSensor Point sensor
- c:
str Name of state
- PS:
- Outputs:
- C:
np.ndarray Array of values for c at each sample
- C:
- Versions:
2015-12-07
@ddalle: First version
- PlotPoint(c, n=None, nAvg=100, **kw)¶
Plot a single point sensor iterative history
- Call:
>>> h = PS.PlotPoint(c, n=None, nAvg=100, **kw)
- Inputs:
- PS:
pyCart.pointsensor.PointSensor Point sensor
- c: {‘dp’} | ‘rho’ | ‘U’ | ‘V’ | ‘W’ | ‘P’
Name of state quantity to plot
- n:
int Only show the last n iterations
- nAvg:
int Use the last nAvg iterations to compute an average
- d:
float Delta in the coefficient to show expected range
- nLast:
int Last iteration to use (defaults to last iteration available)
- nFirst:
int First iteration to plot
- FigWidth:
float Figure width
- FigHeight:
float Figure height
- PS:
- Outputs:
- h:
dict Dictionary of figure/plot handles
- h:
- Versions:
2015-12-07
@ddalle: First version
- Write(fname)¶
Write single-iteration point sensor file
- Call:
>>> PS.Write(fname):
- Inputs:
- PS:
pyCart.pointsensor.PointSensor Point sensor
- fname:
str Name of Cart3D output point sensors file
- PS:
- Versions:
2015-11-30
@ddalle: First version
- copy()¶
Copy a point sensor
- Call:
>>> P2 = PS.copy()
- Inputs:
- PS:
pyCart.pointsensor.PointSensor Point sensor
- PS:
- Outputs:
- P2:
pyCart.pointsensor.PointSensor Point sensor copied
- P2:
- Versions:
2015-11-30
@ddalle: First version
- cape.pycart.pointsensor.get_DataBookNStatsPS()¶
Return info about iterations at which point sensors have been recorded
- cape.pycart.pointsensor.get_InputCntl()¶
Read the best
input.cntlorinput.??.cntlfile- Call:
>>> IC = get_InputCntl()
- Outputs:
- IC:
pyCart.inputcntlfile.InputCntl File interface to Cart3D input file
input.cntl
- IC:
- Versions:
2015-12-04
@ddalle: First version
- cape.pycart.pointsensor.get_iter(fname)¶
Get iteration number from a point sensor single-iteration file
- cape.pycart.pointsensor.get_mach(IC=None)¶
Get Mach number from most appropriate
input.??.cntlfile- Call:
>>> M = get_mach(IC=None)
- Inputs:
- IC:
pyCart.inputcntlfile.InputCntl File interface to Cart3D input file
input.cntl
- IC:
- Outputs:
- M:
float Mach number as determined from Cart3D input file
- M:
- Versions:
2015-12-01
@ddalle: First version