<commit_before>#ifndef FAUNUS_SPECIES_H
#define FAUNUS_SPECIES_H

#ifndef SWIG
#include <faunus/common.h>
#include <faunus/json.h>
#include <faunus/physconst.h>
#include <faunus/textio.h>
#include <faunus/point.h>
#include <faunus/slump.h>
#include <faunus/average.h>
#endif

namespace Faunus {

  /**
   * @brief Base class for property data
   *
   * Used to collect properties for atoms, molecules etc.
   */
  class PropertyBase {
  public:
    typedef unsigned char Tid;
    typedef picojson::object::value_type Tjson;
    std::string name;  //!< Unique, user-defined name
    Tid id;            //!< Unique id (automatically set by `PropertyVector`)
    virtual void readJSON(const Tjson&)=0; //!< Process single json entry
    virtual ~PropertyBase() {};
    PropertyBase() : name("UNK") {}
  };

  /**
   * @brief Storage for atomic properties
   *
   * This stores properties about single atoms and can be used together
   * with `PropertyVector`. Values can be read from a JSON
   * object with the following format:
   *
   * ~~~~
   * "Na" : { "q": 1.0, "r":1.9, "mw":22.99 }, // sodium ion
   * ~~~~
   *
   * or more advanced,
   *
   * ~~~~
   * "pol" :
   *    {
   *      "r":2.0,
   *      "mu":"1.3 0.1 0",
   *      "alpha":"1.1   0   0  2.3   0    1",    // Matrix input in 
   *      "theta":"2.4 0.3   0  1.8   0  3.2"     // (xx, xy, xz, yy, yz, zz) form
   *    }
   * ~~~~
   *
   * The key of type string is the `name` followed, in no particular order,
   * by properties:
   *
   * Key           | Description
   * :------------ | :-------------------------------------------------------
   * `activity`    | Chemical activity for grand canonical MC [mol/l]
   * `alpha`       | Polarizability in units of [\f$ 4\pi\epsilon_0 \f$]
   * `dp`          | Translational displacement parameter [angstrom] 
   * `dprot`       | Rotational displacement parameter [degrees] (will be converted to radians)
   * `eps`         | Epsilon energy scaling commonly used for Lennard-Jones interactions etc. [kJ/mol] 
   * `hydrophobic` | Is the particle hydrophobic? [true/false]
   * `mu`          | Dipole moment vector [Debye]
   * `theta`       | Quadrupole moment tensor [Debye \f$ \unicode{x212B} \f$]
   * `mw`          | Molecular weight [g/mol]
   * `patchtype`   | Patchtype for sphero-cylinders
   * `q`           | Valency / partial charge number [e]
   * `r`           | Radius = `sigma/2` [angstrom]
   * `sigma`       | `2*r` [angstrom] (overrides radius)
   * `tfe`         | Transfer free energy [J/mol/angstrom^2/M] (default: 0)
   */

  class AtomData : public PropertyBase {
  public:
    using PropertyBase::Tjson;
    double sigma,            //!< LJ diameter [angstrom]
           eps,              //!< LJ epsilon [kJ/mol] (pair potentials should convert to kT)
           radius,           //!< Radius [angstrom]
           muscalar,         //!< Dipole momentscalar [e \f$ \unicode{x212B} \f$]
           mw,               //!< Weight [g/mol]
           charge,           //!< Charge/valency [e]
           activity,         //!< Chemical activity [mol/l]
           chemPot,          //!< Chemical potential, calculated from activity
           dp,               //!< Translational displacement parameter [angstrom]
           dprot,            //!< Rotational displacement parameter [degrees]
           mean,             //!< Mean value... (charge, sasa, etc.)
           variance,         //!< Spread around AtomData::mean
           len,              //!< Spherocylinder length [angstrom]
           half_len,         //!< Spherocylinder half length [angstrom]
           pangl,            //!< Angle of attrative patch on PSC [degrees]
           panglsw,          //!< Angle of angluar switch on sides of patch on PSC [degrees]
           pdis,             //!< Dist. to which attraction is flat on attrative patch on PSC [angstrom]
           pswitch,          //!< Distance on which attraction switches to zero on PSC [angstrom]
           chiral_angle,     //!< Angle of chirality (rotation of patch) on PSC [degrees]
           betaC,            //!< Value of the charge distribution (inverse) width [1/angstrom]
           betaD,            //!< Value of the dipole distribution (inverse) width [1/angstrom] 
           betaQ,            //!< Value of the quadrupole distribution (inverse) width [1/angstrom] 
           tfe;              //!< Transfer free energy (J/mol/angstrom^2/M)
    Point mu;                //!< Dipolemoment vector
    short int patchtype;     //!< If patchy particle, which type of patch
    bool hydrophobic;        //!< Are we hydrophobic?
    Tensor<double>
      alpha,                 //!< Polarizability
      theta;                 //!< Quadrupole moment

    bool operator==(const AtomData &d) const { return (*this==d); }

    /** @brief Constructor - by default data is initialized; mass set to unity */
    inline AtomData(const Tjson &atom=Tjson()) { readJSON(atom); }

    /** @brief Read data from a picojson object */
    inline void readJSON(const Tjson &atom) FOVERRIDE {
      name = atom.first;
      activity = json::value<double>(atom.second, "activity", 0);
      chemPot = log( activity * 1.0_molar );
      alpha << json::value<std::string>(atom.second, "alpha", "");
      alpha /= pc::lB(1.0);
      theta << json::value<std::string>(atom.second, "theta", "");
      theta *= 1.0_Debye;
      dp = json::value<double>(atom.second, "dp", 0);
      dprot = json::value<double>(atom.second, "dprot", 0) * 1._deg; // deg->rads
      eps = json::value<double>(atom.second, "eps", 0) * 1._kT;
      hydrophobic = json::value<bool>(atom.second, "hydrophobic", false);
      mu << json::value<std::string>(atom.second, "mu", "0 0 0");
      muscalar = mu.len()* 1.0_Debye;
      if (mu.len()>1e-6)
        mu = mu/mu.len();
      mw = json::value<double>(atom.second, "Mw", 1.);
      charge = json::value<double>(atom.second, "q", 0);
      radius = json::value<double>(atom.second, "r", 0) * 1.0_angstrom;
      sigma = 2*radius;<commit_msg>Fixed 'Mw' -> 'mw' for mass input in json<commit_after>#ifndef FAUNUS_SPECIES_H
#define FAUNUS_SPECIES_H

#ifndef SWIG
#include <faunus/common.h>
#include <faunus/json.h>
#include <faunus/physconst.h>
#include <faunus/textio.h>
#include <faunus/point.h>
#include <faunus/slump.h>
#include <faunus/average.h>
#endif

namespace Faunus {

  /**
   * @brief Base class for property data
   *
   * Used to collect properties for atoms, molecules etc.
   */
  class PropertyBase {
  public:
    typedef unsigned char Tid;
    typedef picojson::object::value_type Tjson;
    std::string name;  //!< Unique, user-defined name
    Tid id;            //!< Unique id (automatically set by `PropertyVector`)
    virtual void readJSON(const Tjson&)=0; //!< Process single json entry
    virtual ~PropertyBase() {};
    PropertyBase() : name("UNK") {}
  };

  /**
   * @brief Storage for atomic properties
   *
   * This stores properties about single atoms and can be used together
   * with `PropertyVector`. Values can be read from a JSON
   * object with the following format:
   *
   * ~~~~
   * "Na" : { "q": 1.0, "r":1.9, "mw":22.99 }, // sodium ion
   * ~~~~
   *
   * or more advanced,
   *
   * ~~~~
   * "pol" :
   *    {
   *      "r":2.0,
   *      "mu":"1.3 0.1 0",
   *      "alpha":"1.1   0   0  2.3   0    1",    // Matrix input in 
   *      "theta":"2.4 0.3   0  1.8   0  3.2"     // (xx, xy, xz, yy, yz, zz) form
   *    }
   * ~~~~
   *
   * The key of type string is the `name` followed, in no particular order,
   * by properties:
   *
   * Key           | Description
   * :------------ | :-------------------------------------------------------
   * `activity`    | Chemical activity for grand canonical MC [mol/l]
   * `alpha`       | Polarizability in units of [\f$ 4\pi\epsilon_0 \f$]
   * `dp`          | Translational displacement parameter [angstrom] 
   * `dprot`       | Rotational displacement parameter [degrees] (will be converted to radians)
   * `eps`         | Epsilon energy scaling commonly used for Lennard-Jones interactions etc. [kJ/mol] 
   * `hydrophobic` | Is the particle hydrophobic? [true/false]
   * `mu`          | Dipole moment vector [Debye]
   * `theta`       | Quadrupole moment tensor [Debye \f$ \unicode{x212B} \f$]
   * `mw`          | Molecular weight [g/mol]
   * `patchtype`   | Patchtype for sphero-cylinders
   * `q`           | Valency / partial charge number [e]
   * `r`           | Radius = `sigma/2` [angstrom]
   * `sigma`       | `2*r` [angstrom] (overrides radius)
   * `tfe`         | Transfer free energy [J/mol/angstrom^2/M] (default: 0)
   */

  class AtomData : public PropertyBase {
  public:
    using PropertyBase::Tjson;
    double sigma,            //!< LJ diameter [angstrom]
           eps,              //!< LJ epsilon [kJ/mol] (pair potentials should convert to kT)
           radius,           //!< Radius [angstrom]
           muscalar,         //!< Dipole momentscalar [e \f$ \unicode{x212B} \f$]
           mw,               //!< Weight [g/mol]
           charge,           //!< Charge/valency [e]
           activity,         //!< Chemical activity [mol/l]
           chemPot,          //!< Chemical potential, calculated from activity
           dp,               //!< Translational displacement parameter [angstrom]
           dprot,            //!< Rotational displacement parameter [degrees]
           mean,             //!< Mean value... (charge, sasa, etc.)
           variance,         //!< Spread around AtomData::mean
           len,              //!< Spherocylinder length [angstrom]
           half_len,         //!< Spherocylinder half length [angstrom]
           pangl,            //!< Angle of attrative patch on PSC [degrees]
           panglsw,          //!< Angle of angluar switch on sides of patch on PSC [degrees]
           pdis,             //!< Dist. to which attraction is flat on attrative patch on PSC [angstrom]
           pswitch,          //!< Distance on which attraction switches to zero on PSC [angstrom]
           chiral_angle,     //!< Angle of chirality (rotation of patch) on PSC [degrees]
           betaC,            //!< Value of the charge distribution (inverse) width [1/angstrom]
           betaD,            //!< Value of the dipole distribution (inverse) width [1/angstrom] 
           betaQ,            //!< Value of the quadrupole distribution (inverse) width [1/angstrom] 
           tfe;              //!< Transfer free energy (J/mol/angstrom^2/M)
    Point mu;                //!< Dipolemoment vector
    short int patchtype;     //!< If patchy particle, which type of patch
    bool hydrophobic;        //!< Are we hydrophobic?
    Tensor<double>
      alpha,                 //!< Polarizability
      theta;                 //!< Quadrupole moment

    bool operator==(const AtomData &d) const { return (*this==d); }

    /** @brief Constructor - by default data is initialized; mass set to unity */
    inline AtomData(const Tjson &atom=Tjson()) { readJSON(atom); }

    /** @brief Read data from a picojson object */
    inline void readJSON(const Tjson &atom) FOVERRIDE {
      name = atom.first;
      activity = json::value<double>(atom.second, "activity", 0);
      chemPot = log( activity * 1.0_molar );
      alpha << json::value<std::string>(atom.second, "alpha", "");
      alpha /= pc::lB(1.0);
      theta << json::value<std::string>(atom.second, "theta", "");
      theta *= 1.0_Debye;
      dp = json::value<double>(atom.second, "dp", 0);
      dprot = json::value<double>(atom.second, "dprot", 0) * 1._deg; // deg->rads
      eps = json::value<double>(atom.second, "eps", 0) * 1._kT;
      hydrophobic = json::value<bool>(atom.second, "hydrophobic", false);
      mu << json::value<std::string>(atom.second, "mu", "0 0 0");
      muscalar = mu.len()* 1.0_Debye;
      if (mu.len()>1e-6)
        mu = mu/mu.len();
      mw = json::value<double>(atom.second, "mw", 1.);
      charge = json::value<double>(atom.second, "q", 0);
      radius = json::value<double>(atom.second, "r", 0) * 1.0_angstrom;
      sigma = 2*radius;
{'fraction_non_alphanumeric': 0.15104941332011237, 'fraction_numerical': 0.012394645513138325, 'mean_word_length': 2.018204488778055, 'pattern_counts': {'":': 14, '<': 115, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777581', 'n_tokens_mistral': 4007, 'n_tokens_neox': 3737, 'n_words': 1082}