{"id":16965043,"url":"https://github.com/propensive/charisma","last_synced_at":"2025-09-12T02:41:03.357Z","repository":{"id":193588097,"uuid":"689112650","full_name":"propensive/charisma","owner":"propensive","description":"Represent chemical formulae in Scala","archived":false,"fork":false,"pushed_at":"2025-01-26T12:12:02.000Z","size":2418,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T03:39:08.938Z","etag":null,"topics":["chemical-elements","chemical-formulas","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-08T20:44:24.000Z","updated_at":"2025-01-26T12:12:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"94bf40c2-91c6-4395-a9f7-db1780e0e494","html_url":"https://github.com/propensive/charisma","commit_stats":null,"previous_names":["propensive/charisma"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/propensive/charisma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcharisma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcharisma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcharisma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcharisma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/charisma/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fcharisma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274744062,"owners_count":25341136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chemical-elements","chemical-formulas","scala"],"created_at":"2024-10-13T23:44:53.974Z","updated_at":"2025-09-12T02:41:03.309Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/charisma/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/charisma/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Charisma\n\n__Representations of chemicals__\n\n__Charisma__ provides a simple representation of chemical elements and formulas in Scala.\n\n## Features\n\n- provides representations (with names) of the 118 chemical elements known since 2015\n- lightweight syntax for constructing molecules from multiples of elements\n- serialization to Unicode strings\n\n\n## Availability\n\n\n\n\n\n\n\n## Getting Started\n\n### Chemical Entities\n\n_Charisma_ provides representations of several increasingly-complex entities from chemistry,\n- chemical elements\n- molecules\n- chemical formulas\n- chemical equations\nwhich can be constructed, usually by composing other entities.\n\n#### Chemical Elements\n\nThe 118 chemical elements known, and assigned names since 2015 are all\nrepresented in the `PeriodicTable` object, as members named after their\nchemical symbol. For example, Hydrogen is `PeriodicTable.H` and Chlorine is\n`PeriodicTable.Cl`. Each element is an instance of `ChemicalElement`, which\ndefines its atomic number, name in English (noting that \"Sulphur\" and\n\"Aluminium\" are preferred over \"Sulfur\" and \"Aluminum\") and chemical symbol.\n\n#### Molecules\n\nElements can be combined to produce molecules, instances of `Molecule`. To\ncombine multiple atoms of the same element into a molecule, we apply an integer\ntype parameter to that element, for example `PeriodicTable.O[2]` is `O₂` and\n`PeriodicTable.C[60]` would be `C₆₀`.\n\nDifferent elements can be combined using the `*` operator. So salt, `NaCl`,\nwould be `Na*Cl`. Or sulphuric acid, `H₂O₄S`, could be constructed as,\n`H[2]*S*O[4]*S`.\n\n#### Chemical Formulas\n\nA `ChemicalFormula` is the addition of several molucules, combined in integer\nmultiples using the `*` operator, and with other molecules with the `+`\noperator. For example, the products of photosynthesis, `C₆H₁₂O₆ + 6O₂` (sugar\nand oxygen), could be written, `C[6]*H[12]*O[6] + O[2]*6`.\n\n#### Chemical equation\n\nA `ChemicalEquation` describes a relationship between two `ChemicalFormula`s,\nand can be constructed using one the arrow operators between two chemical\nformulas. These arrow operators represent different relationsips between the\nsides of the equation, and are as follows:\n- `--\u003e`: net forwards\n- `\u003c-\u003e`: resonance\n- `\u003c=\u003e`: both directions\n- `\u003c~\u003e`: equilibrium\n- `===`: stoichiometric\n\nThese different relationships are reprensented by the enumeration, `Reaction`.\n\nThe `ChemicalEquation#balance` method will determine if the equation is\nbalanced, that is, the number of atoms of each element is the same on the left\nand right sides of the equation.\n\n### Generality\n\nA `ChemicalElement` principally represents the _type_ of an atom and is not, in\ngeneral, interchangeable with a `Molecule`. But in many circumstances, it can\nalso serve to conveniently represent an atom of that element itself. So while a\n`ChemicalElement` is _not_ a `Molecule`, both have the supertype, `Molecular`.\n\nLikewise, `ChemicalElement`, `Molecule` and `ChemicalFormula` (as well as\n`Molecular`) are all subtypes of a further generalization, `Formulable` for\ntypes that can represent a chemical formula.\n\nGenerally, it is better to program to the `Molecular` and `Forbulable`\ninterfaces, rather than `Molecule` or `ChemicalFormula`, for the greatest\nflexibility.\n\n### Molecular properties\n\nMolecular values may be ionized with a positive or negative integer charge. For\nunit charges, a unary `+` or `-` may prefix a `Molecular` value, e.g. `+Na` or\n`-C[2]*H[3]*O[2]` (acetate). The charges of ions or ionic compounds will be\nadded when combined, so `+Na*(-Cl)` (salt) will produce the chargeless\ncompound, NaCl.\n\nA non-unit charge may be specified for any molecule with its `ion` method,\nspecifying its integral charge value.\n\nMolecules in a chemical equation can also be identified as having a particular\nphysical state, namely solid, liquid, gas or aqueous. These four states are\nrepresented by the enumeration, `PhysicalState` as `Solid`, `Liquid`, `Gas` and\n`Aqueous`, and can be specified for any `Molecular` value with its `as` method.\nFor example, `(Na*Cl).as(Aqueous)` represents an aqueous salt solution.\n\nBy default, a molecule's state is unspecified, represented by the `Unset`\nvalue, and any combination of molecules with physical states set (other than\ninteger multiplication) will unset their physical states, since the resultant\nstate cannot be easily and reliably predicted. Therefore, in the earlier\nexample, `(Na*Cl).as(Aqueous)`, the parentheses are important as the aqueous\nstate would otherwise be specified for Chlorine, but unset immediately upon\ncombining with Sodium.\n\n### Rendering\n\n`ChemicalElement`s, `Molecule`s, `ChemicalFormula`s and `ChemicalEquation`s all\nhave `Show` instances which will render the types as text, using appropriate\nUnicode characters for subscripts.\n\nSince the different elements in a molecule could be written in any order with\nthe same meaning, they are canonically written using the [Hill\nSystem](https://en.wikipedia.org/wiki/Chemical_formula#Hill_system).\n\n\n\n\n\n\n## Status\n\nCharisma is classified as __embryotic__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nCharisma is designed to be _small_. Its entire source code currently consists\nof 300 lines of code.\n\n## Building\n\nCharisma will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Charisma?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Charisma's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Charisma and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `charisma`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Charisma's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Charisma are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/charisma/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Charisma\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nCharisma was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nOne person's charisma may lead to figurative _chemistry_ with another.\n\n### Pronunciation\n\n`/kəˈɹɪzmə/`\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo shows a deuterium atom, according to the [Bohr model](https://en.wikipedia.org/wiki/Bohr_model).\n\n## License\n\nCharisma is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fcharisma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Fcharisma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fcharisma/lists"}