<commit_before>/* -*-  mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */

/*
  Evaluates the unfrozen fraction of water.

  Authors: <NAME> (<EMAIL>)
*/

#include <cmath>
#include <boost/math/constants/constants.hpp>
#include "unfrozen_fraction_model.hh"

namespace Amanzi {
namespace Flow {
namespace FlowRelations {

UnfrozenFractionModel::UnfrozenFractionModel(Teuchos::ParameterList& plist) :
    plist_(plist),
    pi_(boost::math::constants::pi<double>())
{
  halfwidth_ = plist_.get<double>("transition width", 1.) / 2.;
  T0_ = plist_.get<double>("freezing point", 273.15);
}

double UnfrozenFractionModel::UnfrozenFraction(double temp) const {
  double adj_temp = temp - T0_;
  double uf;
  if (adj_temp > 0.) {
    uf = 1.;
  } else if (adj_temp < -2*halfwidth_) {
    uf = 0.;
  } else {
    uf = (std::sin(pi_/2. * (adj_temp + halfwidth_)/halfwidth_) + 1.)/2.;
  }
  return uf;
}

double UnfrozenFractionModel::DUnfrozenFractionDT(double temp) const {
  double adj_temp = temp - T0_;
  double duf;
  if (adj_temp > 0.) {
    duf = 0.;
  } else if (adj_temp < -2*halfwidth_) {
    duf = 0.;
  } else {
    duf = std::cos(pi_/2. * (adj_temp + halfwidth_)/halfwidth_)/2. * pi_/2. / halfwidth_;
  }
  return duf;
}


} // namespace
} // namespace
} // namespace<commit_msg>recenters unfrozen fraction freeze point around zero instead of with uf=1 at T=0.  This reflects rethinking of this as an averaging across the water thickness<commit_after>/* -*-  mode: c++; c-default-style: "google"; indent-tabs-mode: nil -*- */

/*
  Evaluates the unfrozen fraction of water.

  Authors: <NAME> (<EMAIL>)
*/

#include <cmath>
#include <boost/math/constants/constants.hpp>
#include "unfrozen_fraction_model.hh"

namespace Amanzi {
namespace Flow {
namespace FlowRelations {

UnfrozenFractionModel::UnfrozenFractionModel(Teuchos::ParameterList& plist) :
    plist_(plist),
    pi_(boost::math::constants::pi<double>())
{
  if (plist_.isParameter("transition width")) {
    Errors::Message message("Unfrozen Fraction Evaluator: parameter changed from \"transition width\" to \"transition width [K]\"");
    Exceptions::amanzi_throw(message);
  }
  halfwidth_ = plist_.get<double>("transition width [K]", 0.2) / 2.;

  if (plist_.isParameter("freezing point")) {
    Errors::Message message("Unfrozen Fraction Evaluator: parameter changed from \"freezing point\" to \"freezing point [K]\"");
    Exceptions::amanzi_throw(message);
  }
  T0_ = plist_.get<double>("freezing point [K]", 273.15);
}

double UnfrozenFractionModel::UnfrozenFraction(double temp) const {
  double adj_temp = temp - T0_;
  double uf;
  if (adj_temp > halfwidth_) {
    uf = 1.;
  } else if (adj_temp < -halfwidth_) {
    uf = 0.;
  } else {
    uf = (std::sin(pi_/2. * adj_temp/halfwidth_) + 1.)/2.;
  }
  return uf;
}

double UnfrozenFractionModel::DUnfrozenFractionDT(double temp) const {
  double adj_temp = temp - T0_;
  double duf;
  if (adj_temp > halfwidth_) {
    duf = 0.;
  } else if (adj_temp < -halfwidth_) {
    duf = 0.;
  } else {
    duf = std::cos(pi_/2. * adj_temp/halfwidth_)/2. * pi_/2. / halfwidth_;
  }
  return duf;
}


} // namespace
} // namespace
} // namespace
{'fraction_non_alphanumeric': 0.15464566929133858, 'fraction_numerical': 0.014803149606299212, 'mean_word_length': 3.6843657817109143, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7324854', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1136, 'n_words': 263}