Quick Reference
Calculations
Calculation |
Function |
Required args |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tip
Single sample: v.calculate_*(...).result — append .result to get values.
Batch: myfile.calculate_*(...) — called on a BatchFile object, no .result needed.
Models
Use v.get_model_names() to print a list of all models.
Mixed |
|
H2O |
|
CO2 |
|
Arguments
Argument |
Type |
Description |
|---|---|---|
|
Sample |
A |
|
float or str |
Temperature in degrees C. Pass a column name (str) for batch calculations. |
|
float or str |
Pressure in bars. Pass a column name (str) for batch calculations. |
|
float or str |
Mole fraction of CO2 in the fluid (0 to 1). Pass a column name (str) for batch. |
|
str |
Model name. Default: |
|
bool |
Return extra values (single-sample only). Default: |
|
bool |
Print progress (batch only). Default: |
Sample
Task |
Syntax |
|---|---|
Create manually |
|
With normalization |
|
With input units |
|
With output units |
|
Extract from file |
|
Get composition |
|
Get normalized |
|
Update composition |
|
BatchFile
Task |
Syntax |
|---|---|
Import CSV or Excel file |
|
Specific sheet (name) |
|
Specific sheet (index) |
|
With normalization |
|
Specify input units (default is wt% oxides) |
|
Specify output units (default is wt% oxides) |
|
From DataFrame |
|
Get all data |
|
Get normalized data |
|
Extract one sample (defaults to return as dict, pass |
|
Normalization
Value |
Description |
|---|---|
|
No normalization is applied. |
|
Normalizes all oxides (including volatiles) to 100 wt%. |
|
Normalizes to 100 wt%, but H2O and CO2 stay fixed while other oxides are reduced proportionally. |
|
Normalizes non-volatile oxides to 100 wt%. Original H2O and CO2 are added on top, so the total may exceed 100%. |
Units
Value |
Description |
|---|---|
|
Weight percent oxides. |
|
Mol fraction oxides. |
|
Mol fraction cations. |
|
Mol fraction on a single-oxygen basis. |
units vs default_units
units tells VESIcal what your input data are in.
default_units tells VESIcal what units to return data in.
Saving
Method |
Description |
|---|---|
Save any VESIcal objects, DataFrames, dicts, or scalars to CSV or Excel with flexible output modes. |
|
Save to a |
|
Save to one CSV file per calculation. |
*these will be deprecated in the next major release.
Examples
Setup
import VESIcal as v
Create a Sample
my_sample = v.Sample({'SiO2': 77.3, 'TiO2': 0.08, ... })
Extract a sample from an imported file:
extracted_sample = myfile.get_sample_composition('SampleOne', asSampleClass=True)
Import an Excel or CSV File
myfile = v.BatchFile('path/to/your/file.xlsx')
# specific sheet by name
myfile = v.BatchFile('path/to/your/file.xlsx', sheet_name="NameOfYourSheet")
# specific sheet by index (0-based)
myfile = v.BatchFile('path/to/your/file.xlsx', sheet_name=0)
Normalization
On import:
my_sample = v.Sample({...}, default_normalization='standard')
myfile = v.BatchFile('file.xlsx', default_normalization='standard')
On existing data:
normed = mysample.get_composition(normalization="standard")
mysample.change_composition(normed)
Normalize an entire BatchFile:
my_normed_data = myfile.get_data(normalization="standard")
myNewData = v.BatchFile(filename=None, dataframe=my_normed_data)
Units
# input is mol fraction oxides, output as mol fraction oxides
my_sample = v.Sample({...}, units='mol_oxides', default_units='mol_oxides')
# input is wt% (default), convert output to mol fraction oxides
myfile = v.BatchFile('file.xlsx', default_units='mol_oxides')
Tips and Tricks
Pull arguments from a file:
myfile.calculate_dissolved_volatiles(
temperature="MyTemps", # column name in your file
pressure="SomePs", # column name in your file
X_fluid=0.35 # single value applied to all samples
).result
Choose a model:
v.get_model_names() # list all available models
v.calculate_saturation_pressure(
sample=my_sample, temperature=900,
model='ShishkinaIdealMixing'
).result
Dissolved Volatile Concentrations
v.calculate_dissolved_volatiles(sample, temperature, pressure, X_fluid)
# single sample
v.calculate_dissolved_volatiles(
sample=my_sample, temperature=1000, pressure=2000, X_fluid=0.5
).result
# batch
myfile.calculate_dissolved_volatiles(temperature=1000, pressure=2000, X_fluid=0.5)
Equilibrium Fluid Compositions
v.calculate_equilibrium_fluid_comp(sample, temperature, pressure)
# single sample
v.calculate_equilibrium_fluid_comp(
sample=my_sample, temperature=1000, pressure=2000
).result
# batch
myfile.calculate_equilibrium_fluid_comp(temperature=1000, pressure=2000)
Saturation Pressures
v.calculate_saturation_pressure(sample, temperature)
# single sample
v.calculate_saturation_pressure(sample=my_sample, temperature=1000).result
# batch
myfile.calculate_saturation_pressure(temperature=1000)
Isobars and Isopleths
v.calculate_isobars_and_isopleths(sample, temperature, pressure_list, isopleth_list)
Single-sample only.
Extra argument |
Description |
|---|---|
|
List of pressures (bars) at which to calculate isobars. |
|
List of X_fluid values at which to calculate isopleths. |
isobars, isopleths = v.calculate_isobars_and_isopleths(
sample=my_sample,
temperature=1000,
pressure_list=[500, 1000, 2000],
isopleth_list=[0.25, 0.5, 0.75]
).result
fig, ax = v.plot(isobars=isobars, isopleths=isopleths)
v.show()
For custom plotting, get smoothed data as a DataFrame:
smoothed = v.vplot.smooth_isobars_and_isopleths(isobars=isobars, isopleths=isopleths)
Degassing Paths
v.calculate_degassing_path(sample, temperature)
Single-sample only.
Extra argument |
Description |
|---|---|
|
Initial percent of exsolved fluid (e.g., |
|
Fraction of fluid removed at each step. |
# closed system (default)
closed = v.calculate_degassing_path(sample=my_sample, temperature=1000).result
# closed system with 2% initial fluid
init = v.calculate_degassing_path(sample=my_sample, temperature=1000, init_vapor=2.0).result
# fully open system
opened = v.calculate_degassing_path(sample=my_sample, temperature=1000, fractionate_vapor=1.0).result
# partially open (20% removed per step)
partial = v.calculate_degassing_path(sample=my_sample, temperature=1000, fractionate_vapor=0.2).result
fig, ax = v.plot(
degassing_paths=[closed, init, opened, partial],
degassing_path_labels=["Closed", "2% Initial Fluid", "Open", "Partly Open"]
)
v.show()
Liquid Density
v.calculate_liquid_density(sample, temperature, pressure)
# single sample
v.calculate_liquid_density(sample=my_sample, temperature=1000, pressure=2000).result
# batch
myfile.calculate_liquid_density(temperature=1000, pressure=2000)
Liquid Viscosity
v.calculate_liquid_viscosity(sample, temperature)
# single sample
v.calculate_liquid_viscosity(sample=my_sample, temperature=1000).result
# batch
myfile.calculate_liquid_viscosity(temperature=1000)
Save Results (General Purpose)
v.save_results(filename, obj, filetype="csv", mode="single_sheet", descriptions=None)
Save any combination of VESIcal objects, DataFrames, dicts, or scalars to CSV or Excel. Supports Sample, Calculate, and BatchFile objects, as well as pandas DataFrames/Series, dictionaries, lists, and scalar values.
Argument |
Description |
|---|---|
|
Base filename. Extension is added or replaced automatically. For |
|
Data to save: a single object or a list of objects. |
|
|
|
|
|
Optional list of string labels added as a |
# Save a single calculation result
v.save_results("satP.csv", satP)
# Save a list of mixed types to Excel, one sheet per item
v.save_results("results.xlsx", [mysample, satP, dissolved],
filetype="excel", mode="multi_sheet",
descriptions=["Sample", "Saturation Pressure", "Dissolved Volatiles"])
# Save each item to its own CSV file
v.save_results("output", [satP, dissolved],
filetype="csv", mode="multi_file")
Old save methods
These will be deprecated in next major release.
Save to Excel
dissolved = myfile.calculate_dissolved_volatiles(temperature=900, pressure=1000, X_fluid=0.5)
SatP = myfile.calculate_saturation_pressure(temperature=900)
myfile.save_excel("myoutput.xlsx", calculations=[dissolved, SatP])
# with custom sheet names
myfile.save_excel("myoutput.xlsx",
calculations=[dissolved, SatP],
sheet_names=["Dissolved", "Saturation Pressures"]
)
Save to CSV
myfile.save_csv(
filename=["my_dissolved_output.csv", "my_SatP_output.csv"],
calculations=[dissolved, SatP]
)