formula2vector {GCDkit}R Documentation

Counting individual atoms in a formula unit

Description

Function counting number of individual atoms in a formula given by a simple text string.

Usage

    formula2vector(formula)

Arguments

formula

character; a mineral formula

Details

This function converts a mineral formula given as a single character string - like.g. 'KAlSi3O8' for K-feldspar - to a vector with all atoms (per formula unit) counted. Elements can be repeated, trivalent Fe has to be denoted as 'FeIII'. Brackets can be used, like '(PO4)2'.

Value

A named numeric vector with numbers of individual atoms.

Author(s)

Vojtěch Janoušek, vojtech.janousek@geology.cz

See Also

idealMineralCompositions plComp olComp minComp

Examples

    formula2vector("NaAlSi3O8")         # Number of apfu per albite formula
    
    formula2vector("6NaAlSiO4·Na2CO3")  # Cancrinite   
    
    formula2vector("CaMg(CO3)2")        # Dolomite    
    
    formula2vector("Ca3FeIII2Si3O12")   # Andradite

[Package GCDkit version 6.2.0 Index]