MolecularWeightCalculator 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package MolecularWeightCalculator --version 1.0.4
NuGet\Install-Package MolecularWeightCalculator -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MolecularWeightCalculator" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MolecularWeightCalculator --version 1.0.4
#r "nuget: MolecularWeightCalculator, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MolecularWeightCalculator as a Cake Addin
#addin nuget:?package=MolecularWeightCalculator&version=1.0.4

// Install MolecularWeightCalculator as a Cake Tool
#tool nuget:?package=MolecularWeightCalculator&version=1.0.4

Molecular Mass Weight Calculator

This is a C# library for calculating the molecular mass of chemical compounds. It allows you to input a chemical formula and computes the total molecular weight by summing up the atomic weights of the constituent elements.

Features

  • Calculate the molecular weight of chemical compounds.
  • Support for standard atomic weights of elements.
  • Simple and intuitive DLL for integration into your projects.

Installation

You can install the Molecular Mass Calculator library via NuGet Package Manager Console:

NuGet\Install-Package MolecularWeightCalculator

Usage

Here's how you can use the library to calculate the molecular weight of a chemical compound:

var molecularMath = new MolecularMath();
string exp1 = "CO2";
var exp1Result = molecularMath.ComputeMass(exp1);
Console.WriteLine($"{exp1}=>{exp1Result}");
//CO2=>44.009

string exp2 = "CaCO3";
var exp2Result = molecularMath.ComputeMass(exp2);
Console.WriteLine($"{exp2}=>{exp2Result}");
//CaCO3=>100.086

string exp3 = "CO2 / CaCO3";
var exp3Result = molecularMath.ComputeMass(exp3);
Console.WriteLine($"{exp3}=>{exp3Result}");
//CO2 / CaCO3=>0.43971184781088263

string exp4 = "C2H2 +2.5 * O2";
var exp4Result = molecularMath.ComputeMass(exp4);
Console.WriteLine($"{exp4}=>{exp4Result}");
//C2H2 +2.5 * O2=>106.033


string exp5 = "2*CO2/C2H2";
var exp5Result = molecularMath.ComputeMass(exp5);
Console.WriteLine($"{exp5}=>{exp5Result}");
//2*CO2/C2H2=>3.3803671556955224

string exp6 = "1*2*3*4";
var exp6Result = molecularMath.ComputeMass(exp6);
Console.WriteLine($"{exp6}=>{exp6Result}");
//1*2*3*4=>24

string exp7 = "CaCO3 * A2 + B3";
//var exp7Result = molecularMath.ComputeMass(exp7);
//Console.WriteLine($"{exp7}=>{exp7Result}");
//KeyNotFoundException: 'A' was not present in the Periodic Table


Console.WriteLine($"===== calculate only contain C (Carbon) =====");
string calcMolecularOnly = "C";
string[] calcMolecularOnlyArray = calcMolecularOnly.Split(',');
string exp8 = "CaO + CO2";
var exp8Result = molecularMath.ComputeMass(exp8, calcMolecularOnlyArray);
Console.WriteLine($"{exp8}=>{exp8Result}");
//CaO + CO2=>44.009 (only CO2)

string exp9 = "C2H2 +2.5*O2";
var exp9Result = molecularMath.ComputeMass(exp9, calcMolecularOnlyArray);
Console.WriteLine($"{exp9}=>{exp9Result}");
//C2H2 +2.5*O2=>26.037999999999997 (Only C2H2)

string expA = "2*CO2 + H2O";
var expAResult = molecularMath.ComputeMass(expA, calcMolecularOnlyArray);
Console.WriteLine($"{expA}=>{expAResult}");
//2*CO2 + H2O=>88.018 (Only 2*CO2)

ChangeLog

1.0.2

  1. fix: change ComputeMass method return type from double to object

1.0.3

  1. change Periodic Table from https://iupac.org/what-we-do/periodic-table-of-elements/

1.0.4

  1. Add filtering to only calculate the molecular weight of compounds with certain chemical elements, such as only contain C (Carbon)

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

License: MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 81 3/6/2024
1.0.4 93 3/5/2024
1.0.3 95 3/4/2024
1.0.2 120 3/1/2024
1.0.1 117 3/1/2024
1.0.0 114 3/1/2024

### 1.0.2

 1. fix: change ComputeMass method return type from double to object

 ### 1.0.3

 1. change Periodic Table from https://iupac.org/what-we-do/periodic-table-of-elements/

 ### 1.0.4

 1. Add filtering to only calculate the molecular weight of compounds with certain chemical elements, such as only contain C (Carbon)