Description: "Return mass fractions X from mole fractions"

- Home > Modelica

## Modelica.Media.Interfaces.PartialMixtureMedium.moleToMassFractions

Return mass fractions X from mole fractions

### Information

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
MoleFraction | moleFractions[:] |  | Mole fractions of mixture [1]
MolarMass | MMX[:] |  | Molar masses of components [kg/mol]

### Outputs

Type | Name | Description
--- | --- | ---
MassFraction | X[size(moleFractions, 1)] | Mass fractions of gas mixture [1]

### Modelica definition

function moleToMassFractions "Return mass fractions X from mole fractions" extends Modelica.Icons.Function; input SI.MoleFraction moleFractions[:] "Mole fractions of mixture"; input MolarMass[:] MMX "Molar masses of components"; output SI.MassFraction X[size(moleFractions, 1)] "Mass fractions of gas mixture"; protected MolarMass Mmix=moleFractions*MMX "Molar mass of mixture"; algorithm for i in 1:size(moleFractions, 1) loop X[i] := moleFractions[i]*MMX[i]/Mmix; end for; end moleToMassFractions;

## Modelica.Media.Interfaces.PartialMixtureMedium.massToMoleFractions

Return mole fractions from mass fractions X

### Information

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
MassFraction | X[:] |  | Mass fractions of mixture [1]
MolarMass | MMX[:] |  | Molar masses of components [kg/mol]

### Outputs

Type | Name | Description
--- | --- | ---
MoleFraction | moleFractions[size(X, 1)] | Mole fractions of gas mixture [1]

### Modelica definition

function massToMoleFractions "Return mole fractions from mass fractions X" extends Modelica.Icons.Function; input SI.MassFraction X[:] "Mass fractions of mixture"; input SI.MolarMass[:] MMX "Molar masses of components"; output SI.MoleFraction moleFractions[size(X, 1)] "Mole fractions of gas mixture"; protected Real invMMX[size(X, 1)] "Inverses of molar weights"; SI.MolarMass Mmix "Molar mass of mixture"; algorithm for i in 1:size(X, 1) loop invMMX[i] := 1/MMX[i]; end for; Mmix := 1/(X*invMMX); for i in 1:size(X, 1) loop moleFractions[i] := Mmix*X[i]/MMX[i]; end for; end massToMoleFractions;