Skip to content

Commit

Permalink
More integers
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhbell committed Feb 24, 2024
1 parent 45cf532 commit 2161a27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/teqp/models/GERG/GERG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class GERG200XCorrespondingStatesTerm{
using resulttype = std::common_type_t<decltype(tau), decltype(molefracs[0]), decltype(delta)>; // Type promotion, without the const-ness
resulttype alphar = 0.0;
auto N = molefracs.size();
if (N != size()){
if (static_cast<std::size_t>(N) != size()){
throw std::invalid_argument("wrong size");
}
for (auto i = 0U; i < N; ++i) {
Expand Down Expand Up @@ -282,7 +282,7 @@ class GERG200XDepartureTerm {
using resulttype = std::common_type_t<decltype(tau), decltype(delta), decltype(molefracs[0])>; // Type promotion, without the const-ness
resulttype alphar = 0.0;
auto N = molefracs.size();
if (N != static_cast<std::size_t>(Fmat.cols())){
if (static_cast<std::size_t>(N) != static_cast<std::size_t>(Fmat.cols())){
throw std::invalid_argument("wrong size");
}

Expand Down
10 changes: 5 additions & 5 deletions include/teqp/models/pcsaft.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ class PCSAFTHardChainContribution{
c.m2_epsilon_sigma3_bar = static_cast<TRHOType>(0.0);
c.m2_epsilon2_sigma3_bar = static_cast<TRHOType>(0.0);
c.d.resize(N);
for (std::size_t i = 0; i < N; ++i) {
for (auto i = 0L; i < N; ++i) {
c.d[i] = sigma_Angstrom[i]*(1.0 - 0.12 * exp(-3.0*epsilon_over_k[i]/T)); // [A]
for (std::size_t j = 0; j < N; ++j) {
for (auto j = 0; j < N; ++j) {
// Eq. A.5
auto sigma_ij = 0.5 * sigma_Angstrom[i] + 0.5 * sigma_Angstrom[j];
auto eij_over_k = sqrt(epsilon_over_k[i] * epsilon_over_k[j]) * (1.0 - kmat(i,j));
Expand Down Expand Up @@ -293,7 +293,7 @@ class PCSAFTMixture {
std::optional<PCSAFTDipolarContribution> dipolar; // Can be present or not
std::optional<PCSAFTQuadrupolarContribution> quadrupolar; // Can be present or not

void check_kmat(std::size_t N) {
void check_kmat(Eigen::Index N) {
if (kmat.cols() != kmat.rows()) {
throw teqp::InvalidArgument("kmat rows and columns are not identical");
}
Expand Down Expand Up @@ -431,7 +431,7 @@ inline auto PCSAFTfactory(const nlohmann::json& spec) {

if (spec.contains("names")){
std::vector<std::string> names = spec["names"];
if (kmat && kmat.value().rows() != names.size()){
if (kmat && static_cast<std::size_t>(kmat.value().rows()) != names.size()){
throw teqp::InvalidArgument("Provided length of names of " + std::to_string(names.size()) + " does not match the dimension of the kmat of " + std::to_string(kmat.value().rows()));
}
return PCSAFTMixture(names, kmat.value_or(Eigen::ArrayXXd{}));
Expand All @@ -455,7 +455,7 @@ inline auto PCSAFTfactory(const nlohmann::json& spec) {
}
coeffs.push_back(c);
}
if (kmat && kmat.value().rows() != coeffs.size()){
if (kmat && static_cast<std::size_t>(kmat.value().rows()) != coeffs.size()){
throw teqp::InvalidArgument("Provided length of coeffs of " + std::to_string(coeffs.size()) + " does not match the dimension of the kmat of " + std::to_string(kmat.value().rows()));
}
return PCSAFTMixture(coeffs, kmat.value_or(Eigen::ArrayXXd{}));
Expand Down
6 changes: 3 additions & 3 deletions include/teqp/models/saftvrmie.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class SAFTVRMieMixture {
const SAFTVRMieChainContributionTerms terms;
const std::optional<SAFTpolar::multipolar_contributions_variant> polar; // Can be present or not

static void check_kmat(const Eigen::ArrayXXd& kmat, std::size_t N) {
static void check_kmat(const Eigen::ArrayXXd& kmat, Eigen::Index N) {
if (kmat.size() == 0){
return;
}
Expand Down Expand Up @@ -940,7 +940,7 @@ inline auto SAFTVRMiefactory(const nlohmann::json & spec){

if (spec.contains("names")){
std::vector<std::string> names = spec["names"];
if (kmat && kmat.value().rows() != names.size()){
if (kmat && static_cast<std::size_t>(kmat.value().rows()) != names.size()){
throw teqp::InvalidArgument("Provided length of names of " + std::to_string(names.size()) + " does not match the dimension of the kmat of " + std::to_string(kmat.value().rows()));
}
return SAFTVRMieMixture(names, kmat);
Expand Down Expand Up @@ -974,7 +974,7 @@ inline auto SAFTVRMiefactory(const nlohmann::json & spec){
}
coeffs.push_back(c);
}
if (kmat && kmat.value().rows() != coeffs.size()){
if (kmat && static_cast<std::size_t>(kmat.value().rows()) != coeffs.size()){
throw teqp::InvalidArgument("Provided length of coeffs of " + std::to_string(coeffs.size()) + " does not match the dimension of the kmat of " + std::to_string(kmat.value().rows()));
}

Expand Down
4 changes: 2 additions & 2 deletions interface/C/teqpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ std::unordered_map<unsigned long long int, std::shared_ptr<teqp::cppinterface::A
void exception_handler(int& errcode, char* message_buffer, const int buffer_length)
{
auto write_error = [&](const std::string& msg){
if (msg.size() < buffer_length){
if (msg.size() < static_cast<std::size_t>(buffer_length)){
strcpy(message_buffer, msg.c_str());
}
else{
std::string toolong_message = "Error message too long for buffer";
if (toolong_message.size() < buffer_length){
if (toolong_message.size() < static_cast<std::size_t>(buffer_length)){
strcpy(message_buffer, toolong_message.c_str());
}
else if (buffer_length > 1){
Expand Down

0 comments on commit 2161a27

Please sign in to comment.