Scripting
While most common operations can be executed through the use of commands, scripting is a vital aspect of PFC, allowing users to perform problem-specific operations. PFC provides scripting capabilities via both the FISH and Python languages, which are described in this section.
FISH is an embedded programming language specific to Itasca software that has been designed for use by non-programmers. FISH has been augmented through the years, yielding a mature and useful tool for undertaking custom scripting in Itasca software. With FISH, users can access model data at any time during the modeling sequence. FISH has a legacy of being extensively used to perform advanced algorithms in PFC.
The Python programming language has been embedded inside PFC since the release of PFC 5.00.20. Python is an open-source, object-oriented, interpreted, and interactive high-level programming language. PFC includes a scientific Python distribution that has been extended to allow one to access PFC model data from Python. In addition, the IPython console has been embedded in PFC to provide an interactive python console.
Note
Both Python and FISH can be used to interact with PFC. The main differences between the two can be summarized as follows:
- Unlike FISH, Python uses an object-oriented programming style to interact with PFC model
components. For instance, one accesses ball data by calling a function with a ball pointer
(e.g.
ball.radius(bp)
where bp is a ball pointer) in FISH. In Python, on the other hand, balls are represented via the Ball class which defines methods for interacting with the balls. For instance, the operation above is undertaken with Python asb.radius()
whereb
is a Ball object (i.e., an instance of the Ball class). - Python does not have automatic variable declaration. In FISH, using a variable before it has been defined creates a new variable initialized to zero. The same operation in Python raises an exception.
- Unlike FISH, the global Python namespace is not connected to the model state. When a
model new
,model save
ormodel restore
command is given, the FISH programming state is cleared, saved or restored; the state of the Python namespace is unchanged by these operations, though. Whereas this can be seen as a limitation of Python usage, it provides also the advantages of being able to automate batch processing with sequences of save and restore operations. - Python has the advantage of being somewhat faster than FISH, easy to use, and has substantial functionalities included in the scientific Python environment distributed with PFC. Since its inception in the 1980’s, Python has become the most widely used programming language in the world. In addition, Python is extensible via a plethora of modules available from the large worldwide user community.
The FISH and Python languages are described in the sections below.
Was this helpful? ... | PFC 6.0 © 2019, Itasca | Updated: Nov 19, 2021 |