PDSim.core package

Submodules

PDSim.core.bearings module

PDSim.core.bearings.journal_bearing(**kwargs)[source]

The necessary calculations for a journal bearing

We only take keyword arguments to avoid problems with order of parameters

Parameters must be specified by name!

Parameters:
  • r_b (float) – Radius of journal [m]

  • L (float) – Length of journal [m]

  • omega (float) – Rotational speed [rad/s]

  • eta_0 (float, or 1d numpy array) – Viscosity of lubricant [Pa-s]

  • W (float) – Applied load [N]

  • c (float) – Bearing clearance [m]

Returns:

output_dict – Dictionary of output terms,

Return type:

dictionary

Notes

Short-bearing analysis is used. Here we are implementing the equations from the Ph.D. dissertation of Jay Kim (Purdue, 2005). Knowing \(w_r\) and the dimensions we can then obtain \(\epsilon\) using a 1D secant solver with the initial guess of \(\epsilon=0.5\). Then we obtain \(F_{shear}\) for the given value of \(\epsilon\).

\[W_r = \frac{w_r}{\eta_0\omega r_b L}\left(\frac{c}{L}\right)^2 = \frac{\epsilon}{4(1-\epsilon^2)^2}[16\epsilon^2+\pi^2(1-\epsilon^2)]^{1/2}\]
\[\mathbf{F}_{shear} = \frac{F_{shear}}{\eta_0\omega r_b L}\left(\frac{c}{r_b}\right) = \frac{2\pi}{(1-\epsilon^2)^{1/2}}\left[\left(\frac{b}{r_b}\right)^2\frac{\epsilon^2}{16(1-\epsilon^2)}+1\right]\]
\[\mu = \frac{F_{shear}}{w_r}\]
PDSim.core.bearings.journal_bearing_design(**kwargs)[source]

The necessary calculations for a journal bearing

We only take keyword arguments to avoid problems with order of parameters

Parameters must be specified by name!

Parameters:
  • r_b (float) – Radius of journal [m]

  • L (float) – Length of journal [m]

  • omega (float) – Rotational speed [rad/s]

  • eta_0 (float) – Viscosity of lubricant [Pa-s]

  • W (float) – Applied load [N]

  • c (float) – Bearing clearance [m]

  • design (string or float) – Either one of 'friction' (design for minimum friction) 'load' (design for maximum load) or a floating point value in the range [0,1] that weights the minimum friction and maximum load parameters and 0 gives the friction solution. Hamrock recommends a value of 0.5 for general applications

Notes

One of design or c must be provided

Based on the method presented by

Raimondi, A. A., and Boyd, J. (1958) : A Solution for the Finite Journal Bearing and Its Application to Analysis and Design-I, -II, and -III. ASLE Trans., vol. 1, no. I, I- pp. 159-174; II- pp. 175-193; III- pp. 194-209.

And further analysis presented in Hamrock:

In Fig. 11.2 a recommended operating eccentricity ratio, or minimum film thickness, is indicated as well as a preferred operating area. The left boundary of the shaded zone defines the optimum eccentricity ratio for a minimum coefficient of friction, and the right boundary the optimum eccentricity ratio for maximum load. The recommended operating eccentricity for general application is midway between these two boundaries.

class PDSim.core.bearings.struct[source]

Bases: object

PDSim.core.bearings.thrust_bearing(**kwargs)[source]

Analysis for the journal bearing

We only take keyword arguments to avoid problems with order of parameters Parameters must be specified by name!

Parameters:
  • mu (float) – Friction coefficient [-]

  • V (float) – Contact velocity [m/s]

  • N (float) – Thrust force [N]

Notes

To derive the speed of contact of the orbiting scroll

\[x = {r_o}\cos \left( {{\phi _{ie}} - \frac{\pi }{2} - \theta } \right)\]
\[y = {r_o}\sin \left( {{\phi _{ie}} - \frac{\pi }{2} - \theta } \right)\]
\[\frac{{dx}}{{d\theta }} = {r_o}\sin \left( {{\phi _{ie}} - \frac{\pi }{2} - \theta } \right)\omega\]
\[\frac{{dy}}{{d\theta }} = - {r_o}\cos \left( {{\phi _{ie}} - \frac{\pi }{2} - \theta } \right)\omega\]
\[\left| v \right| = \sqrt {{{\left( {\frac{{dx}}{{d\theta }}} \right)}^2} + {{\left( {\frac{{dy}}{{d\theta }}} \right)}^2}} = {r_o}\omega\]

But it is quite possible that you do not have hydro-dynamic lubrication, and as a result you can get asperity-asperity contact and much higher friction coefficients - see for example Kobayashi et al. “Experimental Study on Journal Bearing Characteristics in Reciprocating Compressors for HFC-134a” Purdue Compressor Conferences 1998. http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=2257&context=icec

Can be off by a factor of as much as 10 times at low Sommerfeld number

PDSim.core.callbacks module

class PDSim.core.callbacks.CallbackContainer

Bases: object

endcycle_callback

object

Type:

endcycle_callback

heat_transfer_callback

PDSim.core.callbacks.HeatTransferCallback

Type:

heat_transfer_callback

lumps_energy_balance_callback

PDSim.core.callbacks.LumpsEnergyBalanceCallback

Type:

lumps_energy_balance_callback

step_callback

PDSim.core.callbacks.StepCallback

Type:

step_callback

class PDSim.core.callbacks.HeatTransferCallback(Core)

Bases: object

A wrapper to contain the callback that is called to evaluate the heat transfer rate for all of the control volumes. It is not meant to be instantiated directly, rather inherited

Two methods are provided, call(t) and __call__(t). The special method

__call__(t) allows an instance of StepCallback to be called directly like:

SC = StepCallback(core)
SC(t)

or you can call the call() method like:

SC.call(t)

Having both methods allows cython functions to stay at the C++ layer since they can call the .call() function with defined argument types and not need to come back to python layer for speed

call(self, double t) arraym

This is the base class function, so don’t do anything, return all zeros for the heat transfer rate

class PDSim.core.callbacks.LumpsEnergyBalanceCallback(Core)

Bases: object

A wrapper to contain the callback that is called to evaluate the lump energy balance, as well as the error on the discharge temperature

Two methods are provided, call() and __call__(). The special method

__call__() allows an instance of LumpsEnergyBalanceCallback to be called directly like:

LEBC = LumpsEnergyBalanceCallback(core)
LEBC()

or you can call the call() method like:

LEBC.call()

Having both methods allows cython functions to stay at the C++ layer since they can call the .call() function with defined argument types and not need to come back to python layer for speed

call(self) arraym

This is the base class function, so don’t do anything, return all zeros for the heat transfer rate

class PDSim.core.callbacks.StepCallback(Core)

Bases: object

A wrapper to contain the callback that is called when at the beginning of the step, before the step is actually evaluated.

Two methods are provided, call(t,h,i) and __call__(t,h,i). The special method

__call__(t,h,i) allows an instance of StepCallback to be called directly like:

SC = StepCallback(core)
SC(t,h,i)

or you can call the call() method like:

SC.call(t,h,i)

Having both methods allows cython functions to stay at the C++ layer since they can call the .call() function with defined argument types and not need to come back to python layer for speed

call(self, double t, double h, int i) double

This is the base class function, so don’t do anything, use the same step size again

disable_adaptive
h
class PDSim.core.callbacks.WrappedHeatTransferCallback(Core, func)

Bases: HeatTransferCallback

call(self, double t) arraym

This function returns the values from the wrapped function

class PDSim.core.callbacks.WrappedLumpsEnergyBalanceCallback(Core, func)

Bases: LumpsEnergyBalanceCallback

call(self) arraym

This function returns the values from the wrapped function

class PDSim.core.callbacks.WrappedStepCallback(Core, func)

Bases: StepCallback

This class is intended to provide a python-friendly wrapper of the Cython base class so that high-level python code can seamlessly interface through into Cython. It is not as fast as developing a cython Callback function, but it is easier to do

call(self, double t, double h, int i) double

This function returns the values from the wrapped function

PDSim.core.containers module

class PDSim.core.containers.CVArrays

Bases: CVScore

A stub class that contains the arraym arrays of the state variables for all the control volumes that are passed into the instantiator

calculate_derivs(self, double omega, bool has_liquid)
properties_and_volumes(self, list CVs, double theta, int state_vars, arraym x)

Calculate all the required thermodynamic properties as well as the volumes for each control volume.

Parameters:
  • CVs (list of control volumes)

  • theta (double) – Crank angle [radians]

  • state_vars (int) – Flag for the set of input variables - one of STATE_VARS_TM or STATE_VARS_TD defined in this module

  • x (arraym instance) – List of state variables corresponding to the state_vars flag

class PDSim.core.containers.CVScore

Bases: object

The base class for all control volumes

In the derived class, before anything is done, you must set the parameter array_list as a list of strings, each entry in the list should be the name of an arraym instance that will be stored in the class

Q

PDSim.misc.datatypes.arraym

Type:

Q

T

PDSim.misc.datatypes.arraym

Type:

T

V

PDSim.misc.datatypes.arraym

Type:

V

calculate_flows(self, FlowPathCollection Flows)

Calculate the flows between tubes and control volumes and sum up the flow-related terms

Loads the arraym instances summerdT and summerdm of this class

These terms are defined by

\[\mathrm{summerdm} = \sum \frac{\dot m}{\omega}\]

and

\[\mathrm{summerdT} = \sum \frac{\dot m h}{\omega}\]

where the signs are dependent on whether the flow is into or out of the given control volume

Parameters:

Flows (FlowPathCollection instance)

copy(self)

Make copies of all of the arraym instances in this class

cp

PDSim.misc.datatypes.arraym

Type:

cp

cv

PDSim.misc.datatypes.arraym

Type:

cv

dTdtheta

PDSim.misc.datatypes.arraym

Type:

dTdtheta

dV

PDSim.misc.datatypes.arraym

Type:

dV

dmdtheta

PDSim.misc.datatypes.arraym

Type:

dmdtheta

dpdT_constV

PDSim.misc.datatypes.arraym

Type:

dpdT_constV

drhodtheta

PDSim.misc.datatypes.arraym

Type:

drhodtheta

h

PDSim.misc.datatypes.arraym

Type:

h

just_volumes(self, list CVs, double theta)

Just calculate the volumes for each control volume.

Parameters:
  • CVs (list of control volumes)

  • theta (double) – Crank angle [radians]

m

PDSim.misc.datatypes.arraym

Type:

m

p

PDSim.misc.datatypes.arraym

Type:

p

property_derivs

PDSim.misc.datatypes.arraym

Type:

property_derivs

rho

PDSim.misc.datatypes.arraym

Type:

rho

summerdT

PDSim.misc.datatypes.arraym

Type:

summerdT

summerdm

PDSim.misc.datatypes.arraym

Type:

summerdm

update_size(self, int N)

Update the size of the arraym instances in this class

v

PDSim.misc.datatypes.arraym

Type:

v

class PDSim.core.containers.ControlVolume(str key, VdVFcn, State initialState, bool exists=True, dict VdVFcn_kwargs={}, str discharge_becomes=None, becomes=None)

Bases: object

This is a class that contains all the code for a given control volume.

It includes the code for calculation of volumes and others.

ForceFcn

object

Type:

ForceFcn

State

CoolProp.CoolProp.State

Type:

State

V_dV

object

Type:

V_dV

V_dV_kwargs

dict

Type:

V_dV_kwargs

becomes

object

Type:

becomes

discharge_becomes
exists

‘bool’

Type:

exists

key
keyIndex

‘long’

Type:

keyIndex

class PDSim.core.containers.ControlVolumeCollection

Bases: object

ControlVolumeCollection is class to hold all the control volumes

CVs
N
Nexist
Nodes
T

Temperature for each CV that exists

add(self, ControlVolume CV)

Add a control volume to the list of control volumes

Parameters:

CV (ControlVolume instance)

arrays

PDSim.core.containers.CVArrays

Type:

arrays

at(self, int i)

Return the control volume at the given index

cp

Specific heat at constant volume for each CV that exists

cv

Specific heat at constant volume for each CV that exists

dpdT

Derivative of pressure with respect to temperature at constant volume for each CV that exists

exists_CV
exists_indices
exists_keys
get(self, parameters key, double factor=1.0)

Get a value from all the control volumes :param key: The key to get from CoolProp :param factor: The value to multiply each acquired value by :type factor: double

h

Enthalpy for each CV that exists

index(self, key)
indices
keys
p

Pressure for each CV that exists

rebuild_exists(self)

Rebuild all the internal lists that hold the indices, keys, and control volumes

rho

Density for each CV that exists

updateStates(self, str name1, arraym array1, str name2, arraym array2)
volumes(self, double theta, bool as_dict=False)

Each control volume class must define a function V_dV (through a pointer) that defines the volume and derivative of volume with respect to the independent variable. The function that V_dV points to MUST be of the form

V,dV=V_dV(theta,**kwargs)

If the parameter V_dV_kwargs is passed to the class constructor, these keyword arguments will be unpacked into the volume function call. Useful for passing a flag to a given function

Parameters:

as_dict (boolean, optional) – If True, return the volumes and derivatives of volumes as a dictionary

Return type:

A tuple of volumes and derivatives of volumes as arraym instances

class PDSim.core.containers.Tube(key1, key2, L, ID, State1=None, State2=None, OD=-1, fixed=-1, TubeFcn=None, mdot=-1, exists=True)

Bases: object

A tube is a component of the model that allows for heat transfer and pressure drop.

With this class, the state of at least one of the points is fixed. For instance, at the inlet of the compressor, the state well upstream is quasi-steady.

ID

‘double’

Type:

ID

L

‘double’

Type:

L

OD

‘double’

Type:

OD

Q

‘double’

Type:

Q

Q_add

‘double’

Type:

Q_add

State1

CoolProp.CoolProp.State

Type:

State1

State2

CoolProp.CoolProp.State

Type:

State2

TubeFcn

object

Type:

TubeFcn

alpha

‘double’

Type:

alpha

exists

‘bool’

Type:

exists

fixed

‘int’

Type:

fixed

i1

‘int’

Type:

i1

i2

‘int’

Type:

i2

key1
key2
mdot

‘double’

Type:

mdot

class PDSim.core.containers.TubeCollection

Bases: list

Nodes
get_Nodes(self) dict
get_T(self) arraym

Get an arraym instance with the enthalpies of each node in the Tubes collection. In the same order as the indices of the enthalpies, but offset by the number of control volumes in existence

get_h(self) arraym

Get an arraym instance with the enthalpies of each node in the Tubes collection. In the same order as the indices of the enthalpies, but offset by the number of control volumes in existence

get_p(self) arraym

Get an arraym instance with the pressures of each node in the Tubes collection. In the same order as the indices of the pressures, but offset by the number of control volumes in existence

update(self)

_Nodes is a dictionary of flow states for any tubes that exist

update_existence(self, int NCV)

Set the indices for each tube node in the array of enthalpies

First index is equal to NCV since python (& c++) are 0-based indexing

PDSim.core.containers.collect_State_h(list CVList) list
PDSim.core.containers.rebuildCVCollection(CVs)

PDSim.core.core module

class PDSim.core.core.EulerIntegrator(sim, x_state)[source]

Bases: IntegratorMixin, AbstractSimpleEulerODEIntegrator

Mixin class using the functions defined in IntegratorMixin and the generalized simple ODE

class PDSim.core.core.HeunIntegrator(sim, x_state)[source]

Bases: IntegratorMixin, AbstractHeunODEIntegrator

Mixin class using the functions defined in IntegratorMixin and the generalized Heun ODE integrator

class PDSim.core.core.IntegratorMixin(sim, x_state)[source]

Bases: object

This class contains the methods that will be merged with one of the system of ODE integrators and includes the methods that are specific to PDSim

derivs(t, x)[source]
get_initial_array()[source]
post_deriv_callback()[source]
post_integration()[source]

Run this at the end

post_step_callback()[source]
pre_step_callback()[source]
premature_termination()[source]
class PDSim.core.core.PDSimCore(stateVariables=None)[source]

Bases: object

This is the main driver class for the model

This class is not intended to be run on its own. It must be subclassed and extended to provide functions for mass flow, etc.

The basic order of steps that should be followed can be summarized as

  1. Instantiate the subclass of PDSimCore

  2. Add each of the control volumes

  3. Add each of the tubes

  4. Add all the flow models between CV and tubes

  5. Add valves (if applicable)

  6. Connect the callbacks for heat transfer, step, etc.

  7. Run the model

CVs

The ControlVolumeCollection instance that contains all the control volumes in the machine

FlowStorage

A list that contains copies of the FlowPathCollection at each crank angle

Flows

The FlowPathCollection instance

IsentropicNozzleFM(FlowPath, A, **kwargs)[source]

A generic isentropic nozzle flow model wrapper

Parameters:
  • FlowPath (FlowPath instance) – A fully-instantiated flow path model

  • A (float) – throat area for isentropic nozzle model [\(m^2\)]

Returns:

mdot – The mass flow through the flow path [kg/s]

Return type:

float

IsentropicNozzleFMSafe(FlowPath, A, DP_floor, **kwargs)[source]

A generic isentropic nozzle flow model wrapper with the added consideration that if the pressure drop is below the floor value, there is no flow. This was added to handle the case of the injection line where there is no flow out of the injection which greatly increases the numerical stiffness

Parameters:
  • FlowPath (FlowPath) – A fully-instantiated flow path model

  • A (float) – throat area for isentropic nozzle model [\(m^2\)]

  • DP_floor (float) – The minimum pressure drop [kPa]

Returns:

mdot – The mass flow through the flow path [kg/s]

Return type:

float

OBJECTIVE_CYCLE(Td_Tlumps0, X, epsilon_cycle=0.003, epsilon_energy_balance=0.003, cycle_integrator='RK45', OneCycle=False, cycle_integrator_options=None, plot_every_cycle=False)[source]

The Objective function for the energy balance solver

Parameters:
  • Td_Tlumps0 (list) – Discharge temperature and lump temperatures

  • X (arraym instance) – Contains the state variables for all the control volumes in existence, as well as any other integration variables

  • epsilon (float) – Convergence criterion applied to all of the solvers (DEPRECATED!)

  • epsilon_cycle (float) – Cycle-cycle convergence criterion

  • epsilon_energy_balance (float) – Energy balance convergence criterion

  • cycle_integrator (string, one of 'RK45','Euler','Heun') – Which solver is to be used to integrate the steps

  • OneCycle (bool) – If True, stop after one cycle

  • plot_every_cycle (bool) – If True, make the debug plots at every cycle

  • cycle_integrator_options (dict) – Options to be passed to cycle integrator

Valves

The Valves container class

add_CV(CV)[source]

Add a control volume to the model

Parameters:

CV (ControlVolume instance) – An initialized control volume

add_flow(FlowPath)[source]

Add a flow path to the model

Parameters:

FlowPath (FlowPath instance) – An initialized flow path

add_tube(Tube)[source]

Add a tube to the model.

Parameters:

Tube (Tube instance) – An initialized tube.

add_valve(Valve)[source]

Add a valve to the model.

Parameters:

Valve (ValveModel instance) – An initialized valve.

attach_HDF5_annotations(fName)[source]

In this function, annotations can be attached to each HDF5 field

Parameters:

fName (str) – The file name for the HDF5 file that is to be used

calc_boundary_work()[source]

This method calculates the boundary work rate using a trapezoidal integration of

\[\dot W_{pv} = -\int p\frac{dV}{d\theta}\frac{\omega}{2\pi} d\theta\]

for all the control volumes and sets the parameter self.Wdot_pv with the result.

The units of the boundary work are kW.

check_abort()[source]

A callback for use with the graphical user interface to force solver to quit

It will check the Scroll.pipe_abort pipe for a True value, and if it finds one, it will set the Scroll._want_abort value to True which will be read by the main execution thread

Once self._want_abort is True, it will stay latched True until the run is terminated

connect_callbacks(step_callback=None, heat_transfer_callback=None, lumps_energy_balance_callback=None, endcycle_callback=None)[source]

Connect up the callbacks for the simulation

The callbacks must either be unbound methods or methods of a class derived from PDSimCore

No keyword arguments are supported to be passed to the callbacks. The callback is probably a bound method of a PDSimCore instance, in which case you have access to all the data in the class anyway

Parameters:
  • step_callback (function, or StepCallback subclass) –

    If a function is provided, it must have the call signature:

    disable_adaptive,h = step_callback(double t, double h, int i)
    

    where h is the step size that the adaptive solver wants to use, t is the current value of the independent variable, and i is the index in the container variables. The return value disableAdaptive is a boolean value that describes whether the adaptive method should be turned off for this step ( False : use the adaptive method), and h is the step size you want to use. If you don’t want to disable the adaptive method and use the given step size, just:

    return False,h
    

    in your code.

  • heat_transfer_callback (function, or HeatTransferCallback subclass) –

    If a function is provided, the heat_transfer_callback function must have the call signature:

    Q = heat_transfer_callback(double t)
    

    It should return an arraym instance with the same length as the number of CV in existence. The entry in the arraym is positive if the heat transfer is TO the fluid in the CV in order to maintain the sign convention that energy (or mass) input is positive.

  • lumps_energy_balance_callback (function, or LumpsEnergyBalanceCallback subclass) –

    If a function is provided, the lumps_energy_balance_callback function must have the call signature:

    r = lumps_energy_balance_callback()
    

    It should return an arraym instance with the same length as the number of lumps. The entry in r is the value of the energy balance. It will be driven to zero by the solver

connect_flow_functions()[source]

Reconnect function pointers

For pickling purposes, it can sometimes be useful to just give the name of the function relative to the PDSimCore (or derived class). If the function is just a string, reconnect it to the function in the PDSimCore instance

derivs(theta, x)[source]

Evaluate the derivatives of the state variables

derivs() is an internal function that should (probably) not actually be called by any user-provided code, but is documented here for completeness.

Parameters:
  • theta (float) – The value of the independent variable

  • x (arraym instance) – The array of the independent variables (state variables plus valve parameters)

Returns:

dfdt

Return type:

arraym instance

endcycle_callback(eps_wrap_allowed=0.0001)[source]

This function can be called at the end of the cycle if so desired. Its primary use is to determine whether the cycle has converged for a given set of discharge temperatures and lump temperatures.

Parameters:

eps_wrap_allowed (float) – Maximum error allowed, in absolute value

Returns:

redoTrue if cycle should be run again with updated inputs, False otherwise. A return value of True means that convergence of the cycle has been achieved

Return type:

bool

get_prune_keys()[source]

Remove some elements when the simulation finishes that are not very useful and/or are very large when stored to file

Returns:

prune_key_list – A list of HDF5 keys that are to be removed from the HDF5 file.

Return type:

list

guess_outlet_temp(inlet_state, p_outlet, eta_a=0.7)[source]

Function to guess outlet temperature

Using a guess value for the adiabatic efficiency, calculate the guessed outlet temperature. In compressor mode, the adiabatic efficiency is defined by

\[\eta_a = \frac{h_{2s}-h_1}{h_2-h_1}\]

and in expander mode it is defined by

\[\eta_a = \frac{h_2-h_1}{h_{2s}-h_1}\]

This function can also be overloaded by the subclass in order to implement a different guess method

one_cycle(X, cycle_integrator='RK45', cycle_integrator_options=None)[source]

Only run one cycle

Parameters:
  • cycle_integrator (str) – One of ‘RK45’,’Euler’,’Heun’

  • cycle_integrator_options (dict) – options to be passed to the solver function (RK45, Euler, etc.)

post_cycle()[source]

This stuff all happens at the end of the cycle. It is a private method not meant to be called externally

The following things are done:

  1. The boundary work is calculated

  2. The flows are post-processed

  3. The heat transfer is post-processed

  4. The mass flow rate is calculated

  5. The volumetric efficiency is calculated

  6. The adiabatic efficiency is calculated

  7. The isentropic power is calculated

  8. The power input is calculated

post_solve()[source]

Do some post-processing to calculate flow rates, efficiencies, etc.

pre_cycle(x0=None)[source]

This runs before the cycle is run but after pre_run has been called

Parameters:

x0 (arraym instance)

pre_run(N=40000)[source]

This function gets called before the run begins. It builds large matrices to store values, and does other initialization.

precond_solve(**kwargs)[source]

This function is deprecated and will be removed in a future version

reset_initial_state()[source]

Reset the initial state of the core class, typically after doing a preconditioning run

solve(key_inlet=None, key_outlet=None, solver_method='Euler', OneCycle=False, Abort=None, pipe_abort=None, UseNR=False, alpha=0.5, plot_every_cycle=False, x0=None, reset_initial_state=False, timeout=3600, eps_cycle=0.001, eps_energy_balance=0.01, cycle_integrator_options=None, max_number_of_steps=40000, **kwargs)[source]

This is the driving function for the PDSim model. It can be extended through the use of the callback functions

It is highly recommended to call this function using keyword arguments like:

solve(key_inlet = 'inlet.1',
      key_outlet = 'outlet.1', ....)
Parameters:
  • key_inlet (str) – The key for the flow node that represents the upstream quasi-steady point

  • key_outlet (str) – The key for the flow node that represents the upstream quasi-steady point

  • solver_method (str)

  • OneCycle (bool) – If True, stop after just one rotation. Useful primarily for debugging purposes

  • Abort (function) – A function that may be called to determine whether to stop running. If calling Abort() returns True, stop running

  • pipe_abort

  • UseNR (bool) – If True, use a multi-dimensional solver to determine the initial state of the state variables for each control volume

  • alpha (float) – Use a range of (1-alpha)*dx, (1+alpha)*dx for line search if needed

  • plot_every_cycle (bool) – If True, make the plots after every cycle (primarily for debug purposes)

  • x0 (arraym) – The starting values for the solver that modifies the discharge temperature and lump temperatures

  • reset_initial_state (bool) – If True, use the stored initial state from the previous call to solve as the starting value for the thermodynamic values for the control volumes

  • timeout (float) – Number of seconds before the run times out

  • eps_cycle (float) – Cycle-cycle convergence criterion

  • eps_energy_balance (float) – Energy balance convergence criterion

  • cycle_integrator_options (dict) – A dictionary of options to be passed to the cycle integrator

  • max_number_of_steps (int) – Maximum number of steps allowed per rotation

Notes

The callbacks step_callback and endcycle_callback and heat_transfer_callback and lump_energy_balance_callback and valves_callback should now be passed to the connect_callbacks() function before running precond_solve() or solve()

step_callback(t, h, i)[source]

The default step_callback which does nothing

Parameters:
  • t (float) – The current value of the independent variable

  • h (float) – The current step size

  • i (int) – The current index

update_existence()[source]

Update existence flags for Tubes and control volumes

This function is required to be called when the existence of any control volume or tube changes in order to ensure that internal flags are set properly

valves_callback()[source]

This is the default valves_callback function that builds the list of derivatives of position and velocity with respect to the crank angle

It returns a list instance with the valve return values in order

class PDSim.core.core.RK45Integrator(sim, x_state)[source]

Bases: IntegratorMixin, AbstractRK45ODEIntegrator

Mixin class using the functions defined in IntegratorMixin and the generalized RK45 integrator

class PDSim.core.core.struct[source]

Bases: object

PDSim.core.integrators module

class PDSim.core.integrators.AbstractHeunODEIntegrator[source]

Bases: AbstractODEIntegrator

do_integration(N, tmin, tmax)[source]

The Heun system of ODE integrator

Parameters:
  • N (integer) – Number of steps taken. There will be N+1 entries in the state matrices

  • tmin (float) – Starting value of the independent variable. t is in the closed range [tmin, tmax]

  • tmax (float) – Ending value for the independent variable. t is in the closed range [tmin, tmax]

Returns:

If an abort has been requested (by returning a value other than False from premature_termination), return value from premature_termination. None otherwise

Return type:

abort_flag

class PDSim.core.integrators.AbstractODEIntegrator[source]

Bases: object

abstractmethod derivs()[source]
abstractmethod do_integration()[source]
abstractmethod get_initial_array()[source]
abstractmethod post_deriv_callback()[source]
abstractmethod post_step_callback()[source]
abstractmethod pre_step_callback()[source]
class PDSim.core.integrators.AbstractRK45ODEIntegrator[source]

Bases: AbstractODEIntegrator

do_integration(tmin=0, tmax=6.283185307179586, hmin=0.0001, eps_allowed=1e-10, step_relax=0.9, valves_callback=None, UseCashKarp=True, **kwargs)[source]

This function implements an adaptive Runge-Kutta-Feldberg 4th/5th order solver for the system of equations

Parameters:
  • hmin (float) – Minimum step size, something like 1e-5 usually is good. Don’t make this too big or you may not be able to get a stable solution

  • tmin (float) – Starting value of the independent variable. t is in the closed range [tmin, tmax]

  • tmax (float) – Ending value for the independent variable. t is in the closed range [tmin, tmax]

  • eps_allowed (float) – Maximum absolute error of any CV per step allowed. Don’t make this parameter too big or you may not be able to get a stable solution. Also don’t make it too small because then you are going to run into truncation error.

  • step_relax (float, optional) – The relaxation factor that is used in the step resizing algorithm. Should be less than 1.0; you can play with this parameter to improve the adaptive resizing, but should not be necessary.

Returns:

If an abort has been requested (by returning a value other than False from premature_termination), return value from premature_termination. None otherwise

Return type:

abort_flag

Notes

Mathematically the adaptive solver can be expressed as:

k1=h*dy(xn                                                                   ,t)
k2=h*dy(xn+1.0/4.0*k1                                                        ,t+1.0/4.0*h)
k3=h*dy(xn+3.0/32.0*k1+9.0/32.0*k2                                           ,t+3.0/8.0*h)
k4=h*dy(xn+1932.0/2197.0*k1-7200.0/2197.0*k2+7296.0/2197.0*k3                ,t+12.0/13.0*h)
k5=h*dy(xn+439.0/216.0*k1-8.0*k2+3680.0/513.0*k3-845.0/4104.0*k4             ,t+h)
k6=h*dy(xn-8.0/27.0*k1+2.0*k2-3544.0/2565.0*k3+1859.0/4104.0*k4-11.0/40.0*k5 ,t+1.0/2.0*h)

where the function dy(y,t) returns a vector of the ODE expressions. The new value is calculated from:

xnplus=xn+gamma1*k1+gamma2*k2+gamma3*k3+gamma4*k4+gamma5*k5+gamma6*k6

In the adaptive solver, the errors for a given step can be calculated from:

error=1.0/360.0*k1-128.0/4275.0*k3-2197.0/75240.0*k4+1.0/50.0*k5+2.0/55.0*k6

If the maximum absolute error is above allowed error, the step size is decreased and the step is tried again until the error is below tolerance. If the error is better than required, the step size is increased to minimize the number of steps required.

Before the step is run, a callback the step_callback method of this class is called. In the step_callback callback function you can do anything you want, but you must return

class PDSim.core.integrators.AbstractSimpleEulerODEIntegrator[source]

Bases: AbstractODEIntegrator

do_integration(N, tmin, tmax)[source]

The simple Euler ODE integrator

Parameters:
  • N (integer) – Number of steps taken (not including the initial step).

  • tmin (float) – Starting value of the independent variable. t is in the closed range [tmin, tmax]

  • tmax (float) – Ending value for the independent variable. t is in the closed range [tmin, tmax]

Returns:

If an abort has been requested (by returning a value other than False from premature_termination), return value from premature_termination. None otherwise

Return type:

abort_flag

PDSim.core.journal_bearing module

PDSim.core.journal_bearing.OBJECTIVE(phi_star, epsilon, plot=False, output=False)[source]
PDSim.core.journal_bearing.TwoDGriddedIntegrate(I, N)[source]
PDSim.core.journal_bearing.TwoDGriddedIntegrate2(PHI, Y, I)[source]

PDSim.core.mobility module

From Flores 2006, JOURNAL BEARINGS SUBJECTED TO DYNAMIC LOADS: THE ANALYTICAL MOBILITY METHOD

PDSim.core.motor module

class PDSim.core.motor.Motor[source]

Bases: object

A class that implements the motor model

This can be either a constant efficiency model

apply_map(tau, kind='linear')[source]

Actually use the motor map to calculate the slip speed and the motor efficiency

Parameters:
  • tau (float) – Torque [N-m]

  • kind (string, optional) – The kind of interpolation to do (see scipy.interpolate.interp1d) - deprecated

Returns:

  • eta (float) – Efficiency [-]

  • omega (float) – Rotational speed [rad/s]

invert_map(Wdot, kind='linear')[source]

Invert the map to calculate the speed and the torque based on the power the power is given by tau*omega

If a constant efficiency, just return (efficiency,None) tuple

plot_eta(ax)[source]

Plot eta v. torque on the given axis

plot_speed(ax)[source]

Plot slip speed v. torque on the given axis

set_coeffs(tau_coeffs, eta_coeffs, omega_coeffs)[source]

Set the coefficients

Parameters:
  • tau_coeffs (iterable (list or similar)) – Values for the torque [N-m]

  • eta_coeffs (iterable (list or similar)) – Values for the efficiency [-] (in the range 0 to 1)

  • omega_coeffs (iterable (list or similar)) – Values for the rotational speed [rad/s]

set_eta(eta)[source]

Set the motor efficiency

Module contents