Skip to content

Commit

Permalink
Changes to satisfy 88 character limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lavdwall authored and ischoegl committed Oct 1, 2021
1 parent 235e074 commit 77d50c6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 30 deletions.
12 changes: 8 additions & 4 deletions include/cantera/transport/GasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ class GasTransport : public Transport

//! Return the polynomial fits to the collision integral of species pair (i, j)
//! @see fitCollisionIntegrals()
virtual void getCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs) const;
virtual void getCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs) const;

//! Modify the polynomial fits to the viscosity of species i
//! @see fitProperties()
Expand All @@ -146,8 +148,10 @@ class GasTransport : public Transport

//! Modify the polynomial fits to the collision integral of species pair (i, j)
//! @see fitCollisionIntegrals()
virtual void setCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs, bool actualT);
virtual void setCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs, bool actualT);

virtual void init(ThermoPhase* thermo, int mode=0, int log_level=0);

Expand Down
12 changes: 8 additions & 4 deletions include/cantera/transport/TransportBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,10 @@ class Transport
}

//! Return the polynomial fits to the collision integral of species pair (i, j)
virtual void getCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs) const{
virtual void getCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs) const{
throw NotImplementedError("Transport::getCollisionIntegralPolynomial");
}

Expand All @@ -622,8 +624,10 @@ class Transport
}

//! Modify the polynomial fits to the collision integral of species pair (i, j)
virtual void setCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs, bool flag){
virtual void setCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs, bool flag){
throw NotImplementedError("Transport::setCollisionIntegralPolynomial");
}

Expand Down
54 changes: 36 additions & 18 deletions interfaces/cython/cantera/transport.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ cdef np.ndarray get_transport_polynomial(
return data

cdef np.ndarray get_binary_transport_polynomial(
Transport tran, transportPolyMethod2i method, int indexi, int indexj, int n_coeffs):
Transport tran, transportPolyMethod2i method, int indexi, int indexj,
int n_coeffs):
cdef np.ndarray[np.double_t, ndim=1] data = np.empty(n_coeffs)
method(tran.transport, indexi, indexj, &data[0])
return data
Expand Down Expand Up @@ -282,13 +283,15 @@ cdef class Transport(_SolutionBase):
"""Get the polynomial fit to the logarithm of temperature for
the thermal conductivity of species i."""
n_values = 4 if self.transport.CKMode() else 5
return get_transport_polynomial(self, tran_getConductivityPolynomial, i, n_values)
return get_transport_polynomial(self, tran_getConductivityPolynomial, i,
n_values)

def get_binary_diff_coeffs_polynomial(self, i, j):
"""Get the polynomial fit to the logarithm of temperature for
the binary diffusion coefficient of species i and j."""
n_values = 4 if self.transport.CKMode() else 5
return get_binary_transport_polynomial(self, tran_getBinDiffusivityPolynomial, i, j, n_values)
return get_binary_transport_polynomial(self, tran_getBinDiffusivityPolynomial,
i, j, n_values)

def get_collision_integral_polynomials(self, i, j):
"""Get the polynomial fit to the logarithm of temperature for
Expand All @@ -297,7 +300,8 @@ cdef class Transport(_SolutionBase):
cdef np.ndarray[np.double_t, ndim=1] adata = np.empty(n_values)
cdef np.ndarray[np.double_t, ndim=1] bdata = np.empty(n_values)
cdef np.ndarray[np.double_t, ndim=1] cdata = np.empty(n_values)
self.transport.getCollisionIntegralPolynomial(i, j, &adata[0], &bdata[0], &cdata[0])
self.transport.getCollisionIntegralPolynomial(i, j, &adata[0], &bdata[0],
&cdata[0])
return adata, bdata, cdata

def set_viscosity_polynomial(self, i, values):
Expand All @@ -306,8 +310,10 @@ cdef class Transport(_SolutionBase):
n_values = 4 if self.transport.CKMode() else 5
if len(values) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(values)}.")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values, dtype=np.double)
f"""Array has incorrect length: expected {n_values} but
received {len(values)}.""")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values,
dtype=np.double)
tran_setViscosityPolynomial(self.transport, i, &data[0])

def set_thermal_conductivity_polynomial(self, i, values):
Expand All @@ -316,8 +322,10 @@ cdef class Transport(_SolutionBase):
n_values = 4 if self.transport.CKMode() else 5
if len(values) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(values)}.")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values, dtype=np.double)
f"""Array has incorrect length: expected {n_values} but
received {len(values)}.""")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values,
dtype=np.double)
tran_setConductivityPolynomial(self.transport, i, &data[0])

def set_binary_diff_coeffs_polynomial(self, i, j, values):
Expand All @@ -326,27 +334,37 @@ cdef class Transport(_SolutionBase):
n_values = 4 if self.transport.CKMode() else 5
if len(values) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(values)}.")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values, dtype=np.double)
f"""Array has incorrect length: expected {n_values} but
received {len(values)}.""")
cdef np.ndarray[np.double_t, ndim=1] data = np.ascontiguousarray(values,
dtype=np.double)
tran_setBinDiffusivityPolynomial(self.transport, i, j, &data[0])

def set_collision_integral_polynomial(self, i, j, avalues, bvalues, cvalues, actualT=True):
def set_collision_integral_polynomial(self, i, j, avalues, bvalues, cvalues,
actualT=True):
"""Get the polynomial fit to the logarithm of temperature for
the collision integral of species i and j."""
n_values = 7 if self.transport.CKMode() else 9
if len(avalues) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(avalues)}.")
f"""Array has incorrect length: expected {n_values} but
received {len(avalues)}.""")
if len(bvalues) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(bvalues)}.")
f"""Array has incorrect length: expected {n_values} but
received {len(bvalues)}.""")
if len(cvalues) != n_values:
raise ValueError(
f"Array has incorrect length: expected {n_values} but received {len(cvalues)}.")
cdef np.ndarray[np.double_t, ndim=1] adata = np.ascontiguousarray(avalues, dtype=np.double)
cdef np.ndarray[np.double_t, ndim=1] bdata = np.ascontiguousarray(bvalues, dtype=np.double)
cdef np.ndarray[np.double_t, ndim=1] cdata = np.ascontiguousarray(cvalues, dtype=np.double)
self.transport.setCollisionIntegralPolynomial(i, j, &adata[0], &bdata[0], &cdata[0], actualT)
f"""Array has incorrect length: expected {n_values} but
received {len(cvalues)}.""")
cdef np.ndarray[np.double_t, ndim=1] adata = np.ascontiguousarray(avalues,
dtype=np.double)
cdef np.ndarray[np.double_t, ndim=1] bdata = np.ascontiguousarray(bvalues,
dtype=np.double)
cdef np.ndarray[np.double_t, ndim=1] cdata = np.ascontiguousarray(cvalues,
dtype=np.double)
self.transport.setCollisionIntegralPolynomial(i, j, &adata[0], &bdata[0],
&cdata[0], actualT)

cdef class DustyGasTransport(Transport):
"""
Expand Down
12 changes: 8 additions & 4 deletions src/transport/GasTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,10 @@ void GasTransport::getBinDiffusivityPolynomial(size_t i, size_t j, double* coeff
}
}

void GasTransport::getCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs) const
void GasTransport::getCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs) const
{
for (size_t k = 0; k < (m_mode == CK_Mode ? 6 : COLL_INT_POLY_DEGREE) + 1; k++) {
astar_coeffs[k] = m_astar_poly[m_poly[i][j]][k];
Expand Down Expand Up @@ -901,8 +903,10 @@ void GasTransport::setBinDiffusivityPolynomial(size_t i, size_t j, double* coeff
m_temp = -1;
}

void GasTransport::setCollisionIntegralPolynomial(size_t i, size_t j, double* astar_coeffs,
double* bstar_coeffs, double* cstar_coeffs, bool actualT)
void GasTransport::setCollisionIntegralPolynomial(size_t i, size_t j,
double* astar_coeffs,
double* bstar_coeffs,
double* cstar_coeffs, bool actualT)
{
int degree = (m_mode == CK_Mode ? 6 : COLL_INT_POLY_DEGREE);
vector_fp ca(degree+1), cb(degree+1), cc(degree+1);
Expand Down

0 comments on commit 77d50c6

Please sign in to comment.