Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Interactive Shell

Ji WenCong edited this page Oct 14, 2017 · 1 revision

Interactive Shell

Get started

BCE has an interactive shell called "bce-console". You can run it in your terminal or Command Prompt (if you haven't installed BCE yet, see ). Type:

bce-console

You will see following shell (banner text may be different):

BCE V4.7.9614
Copyright (C) 2014 - 2015 The BCE Authors. All rights reserved.
>> 

Type unbalanced chemical equation after ">>" and press Enter key, like following:

>> CH4+O2=CO2+H2O
CH4+2O2=CO2+2H2O

The interactive shell will show the balanced chemical equation after calculation. If error occurred, you will see some error messages like:

>> na+Cl2=NaCl
A parser error occurred (Code: PE.ML.UNRECOGNIZED_TOKEN):

Description:

    Unrecognized token.

Traceback:

    na+Cl2=NaCl
    ^^
    An error occurred when parsing the molecule.

    na
    ^
    This token is unexpected.

Parameter

Overview

Argument Description
-h, --help Show help message and exit.
--output-mathml Show output in MathML format.
--disable-banner Disable the start-up banner.
--disable-bundled-abbreviations Disable bundled abbreviations.
--disable-error-correction Disable the error-correction feature.
--disable-auto-arranging Disable the auto-arranging feature.
--unknown-header Set the header of unknown symbols.
--load-abbreviations-file Load extra abbreviations from file.
--language Set the software language.
--version Show the software version.

Custom software language

The program use your system language by default. If your system language is not supported, the program will use English(US).

If you don't want to use the default language, you can use "--language" command line to specify the displaying language.

For example, if you want to use Chinese(Simplified) as the displaying language, just type:

bce-console --language zh_cn

In this example, "zh_cn" is the language code. Currently, following languages are supported:

Language Code
English (US) en, en_US
Chinese (Simplified) zh_cn, zh_hans

Abbreviation Definition File

You can customize your own abbreviations by writing a abbreviation definition file in JSON format.

For example:

{
    "AcOH": "CH3COOH",
    "PhOH": "[Ph]OH"
}

Save it so "custom.json" and run BCE with command line "--load-abbreviations-file" like following:

bce-console --load-abbreviations-file custom.json

Now you can use your customized abbreviations now. For example:

>> [PhOH]+O2=CO2+H2O
[PhOH]+7O2=6CO2+3H2O

Custom Unknown Header

In order to handle chemical equations that have multiple balanced coefficients, the program has to generate a set of unknowns to represent the coefficients.

For example:

>> KI+O3=KIO3+O2
{3*Xa}KI+{3*Xa+2*Xb}O3={3*Xa}KIO3+{3*Xb}O2

In this example, "Xa" and "Xb" are generated by the program. In order to distinguish them from other unknowns, the program will add a header (such as "X") to each generated unknown.

You can customize the unknown header with command line "–unknown-header".

For example:

bce-console --unknown-header Y

Now type the example above again. You will see a different solution:

>> KI+O3=KIO3+O2
{3*Ya}KI+{3*Ya+2*Yb}O3={3*Ya}KIO3+{3*Yb}O2

Another thing you may pay attention to is that unknowns start with the header are reserved (protected) by the program. You can't use unknowns start with the header. Otherwise, you will got an error raised by the program like following:

>> C{Y}H{2Y+2}+O2=CO2+H2O
A parser error occurred (Code: PE.MEXP.USE_PROTECTED_HEADER):

Description:

    Used protected header.

Traceback:

    C{Y}H{2Y+2}+O2=CO2+H2O
    ^^^^^^^^^^^
    An error occurred when parsing the molecule.

    C{Y}H{2Y+2}
     ^^^
     An error occurred when parsing and evaluating this math expression.

    {Y}
     ^
     This symbol begins with the protected symbol header 'Y'.

Clone this wiki locally