Skip to content

Commit bc24cdb

Browse files
committed
Bug fix in longrangeforce. Version 2.67
1 parent 8fb064d commit bc24cdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+64443
-91
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Changelog
22

3+
4+
### 2.67 (11/2/21)
5+
6+
- Fixed a bug in longrangeforce command.
7+
38
### 2.66.1 (10/28/21)
49

510
- Maintainence release. Enabled Python 3.10 wheels.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if(NOT SMOLDYN_VERSION)
3030
else()
3131
# minute-ly release.
3232
string(TIMESTAMP STAMP "%Y%m%d%H%M")
33-
set(SMOLDYN_VERSION "2.67.dev${STAMP}")
33+
set(SMOLDYN_VERSION "2.68.dev${STAMP}")
3434
endif()
3535
endif()
3636
endif()

docs/Smoldyn/SmoldynCodeDoc.pdf

1.6 KB
Binary file not shown.

docs/Smoldyn/SmoldynCodeDoc.rst

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Smoldyn Code Documentation
33
==========================
44
------------
5-
Version 2.66
5+
Version 2.67
66
------------
77

88
:Author: Steve Andrews
9-
:Date: ©June, 2021
9+
:Date: ©November, 2021
1010

1111
Programmer’s introduction
1212
=========================
@@ -11106,6 +11106,18 @@ Individual command functions
1110611106
purged from this list, partly because those molecules might have
1110711107
gone away due to reactions.
1110811108

11109+
The ``scanportion`` region scans over all molecules that fit the
11110+
:math:`species_1` category. Each of these molecules is returned, one
11111+
at a time, in ``mptr``. This ``mptr`` is added to ``moleclist``. The
11112+
function then scans over all possible :math:`species_2` molecules
11113+
that are within ``rmax`` distance of this molecule and checks to see
11114+
if they interact. The ``duplicate`` test investigates whether
11115+
``mptr2`` is an instance of :math:`species_1` because if it is, then
11116+
it’s already in the ``moleclist``, and if it’s not then it needs to
11117+
be put in that list, which is done. If it’s put in the list, then
11118+
that might shift the list by one, in which case ``j`` becomes
11119+
incorrect; to address this, ``j`` is recomputed.
11120+
1110911121
*Internal functions*
1111011122
``void cmdv1free(cmdptr cmd);``
1111111123
|
@@ -11170,6 +11182,94 @@ the shell. This source code file is not included in Libsmoldyn.
1117011182
``smolsimulate`` or ``smolsimulategl`` to run the simulation. At
1117111183
the end, it returns to the shell.
1117211184

11185+
Libsmoldyn (functions in libsmoldyn.cpp)
11186+
----------------------------------------
11187+
11188+
Libsmoldyn is a C/C++ API for the Smoldyn code. It is designed to be
11189+
redundant with the configuration file input, but accessible from code.
11190+
This description is far from complete but needs to be finished at some
11191+
point. See also documentation for it in the SmoldynManual.
11192+
11193+
Error handling
11194+
~~~~~~~~~~~~~~
11195+
11196+
Essentially every user-accessible function returns an error code. Also,
11197+
functions define their function name in
11198+
``const char* funcname="``\ :math:`function`\ ``";``. Errors are checked
11199+
with either the ``LCHECK`` or ``LCHECKNT`` macros. These are supposed to
11200+
differ with ``LCHECK`` dealing with the error itself and throwing an
11201+
exception if necessary, and the ``LCHECKNT`` (no throw) macro not
11202+
dealing with the error but just copying the message over into global
11203+
variables. However, in practice, throwing doesn’t work anyhow, so the
11204+
only real difference is that the regular version displays an error
11205+
message to standard error, whereas the ``NT`` version doesn’t. Anyhow,
11206+
if an error is detected, these macros send the function name, the error
11207+
code, a string error message, and any simulation flags to the libsmoldyn
11208+
functions ``smolSetError`` or ``smolSetErrorNT``.
11209+
11210+
At ``smolSetError`` and ``smolSetErrorNT``, which are essentially
11211+
identical, several function inputs are copied over to global variables:
11212+
the function name to ``Liberrorfunction``, the error code to
11213+
``Liberrorcode``, and the error message to ``Liberrorstring``. These
11214+
items are also displayed to standard error if appropriate.
11215+
11216+
The global error variables are pretty much only used in one place, which
11217+
is the ``smolGetError`` function, which copies their values over to new
11218+
variables and returns those to the calling code. In addition, each
11219+
function in the library returns ``Liberrorcode``, which it just set if
11220+
an error occurred.
11221+
11222+
A few more error handling steps arise if ``smolPrepareSimFromFile`` or
11223+
``smolLoadSimFromFile`` are used.
11224+
11225+
In ``smolLoadSimFromFile``, this calls the smolsim.c function
11226+
``loadsim``. Here, errors are written by the macro ``CHECKS``, which
11227+
copies the error message to the global variable ``ErrorString``. Errors
11228+
are then handled by ``simParseError``, which concatenates the error
11229+
message from ``Parse_ReadFailure`` (the file name and file line) with
11230+
the error message from ``ErrorString``. ``simParseError`` sends the
11231+
result off to ``simLog``, which writes the error to a logfile if one has
11232+
been created or to standard output otherwise.
11233+
11234+
Here is a typical example of error handling. Starting with stand-alone
11235+
Smoldyn first, the program starts in ``main`` in smoldyn.cpp, which
11236+
calls ``simInitAndLoad`` in smolsim.c, which calls ``loadsim``, which
11237+
calls ``simreadstring``. In the ``simreadstring`` function, the input
11238+
parser encounters an error. It writes an error message to the global
11239+
variable ``ErrorString``, goes to its failure label, and then on to
11240+
``simParseError``. Here, ``Parse_ReadFailure`` is called and sent an
11241+
empty string, and that function returns the string with text that reads
11242+
“Error reading file in line *number*. \\n line: *text of line* \\n file:
11243+
*filename*”; if the input line included substituted text, it also gives
11244+
the substituted version of the line in the string as well.
11245+
``Parse_ReadFailure`` also closes files and stops the input process.
11246+
Back in ``simParseError``, the input file information is concatanated
11247+
with the error message to create the complete error string. This is done
11248+
twice; first to create an error string in the global variable
11249+
``ErrorLineAndString`` and also as the input to ``simLog``. The
11250+
``simLog`` function prints the error message to the logging file if one
11251+
was declared or to standard output if not (unless the ‘s’ runtime flags
11252+
was selected, in which case the error output is supressed). Next,
11253+
``simParseError`` returns to ``simreadstring``, which returns an error
11254+
code to ``loadsim``, which returns an error code to ``simInitAndLoad``,
11255+
which returns an error code to ``main``. Here, the code sees the error
11256+
message, skips the simulation, and quits with an exit code of 0.
11257+
11258+
For Libsmoldyn, the flow is similar, but here an entry point is
11259+
``smolPrepareSimFromFile``. This calls ``simInitAndLoad``. As before, an
11260+
error is encountered, it is displayed to the standard output if the ‘s’
11261+
flag isn’t selected (it often should be selected for Libsmoldyn use) and
11262+
also written to ``ErrorLineAndString``. Then, control returns back to
11263+
``smolPrepareSimFromFile``. This sees the error, so it follows the
11264+
``LCHECK`` macro to head off to ``smolSetError``, with the
11265+
``ErrorLineAndString`` contents as the error message. This function
11266+
prints the error message out a second time, which is a little inelegant,
11267+
and also copies the message into the library global variable
11268+
``Liberrorstring``. At this point, control returns to the calling
11269+
program. If desired, that program can then call ``smolGetError`` to get
11270+
the error string again, now in a string variable rather than displayed
11271+
to the output.
11272+
1117311273
Code design
1117411274
===========
1117511275

@@ -14490,6 +14590,30 @@ Modifications for version 2.27 (released 7/26/12)
1449014590

1449114591
- Minor additions to Python API: Simulation.counts and getError.
1449214592

14593+
.. rubric:: Modifications for version 2.66 (not released yet)
14594+
:name: modifications-for-version-2.66-not-released-yet
14595+
:class: unnumbered
14596+
14597+
- Added “-s” command line flag for silent operation.
14598+
14599+
- Improved error reporting for Libsmoldyn ``smolPrepareSimFromFile``
14600+
and ``smolLoadSimFromFile`` functions.
14601+
14602+
- Added a test for Perl availability in bngrunBNGL, in smolbng.c.
14603+
14604+
- Added smolGetSpecies function to libsmoldyn. I haven’t tested it yet.
14605+
14606+
.. rubric:: Modifications for version 2.67 (released 11/2/21)
14607+
:name: modifications-for-version-2.67-released-11221
14608+
:class: unnumbered
14609+
14610+
- Dilawar fixed a typo in the filament code.
14611+
14612+
- Fixed the ``longrangeforce`` command, where an index value could be
14613+
off by one.
14614+
14615+
- Jonathan Karr and Dilawar updated the Biosimulators links.
14616+
1449314617
The wish/ to do list
1449414618
====================
1449514619

docs/Smoldyn/SmoldynCodeDoc.tex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
\pretolerance=10000
4343

4444
\title{Smoldyn Code Documentation}
45-
\subtitle{Version 2.66}
46-
\date{\copyright June, 2021}
45+
\subtitle{Version 2.67}
46+
\date{\copyright November, 2021}
4747
\author{Steve Andrews}
4848
\maketitle
4949

@@ -5463,6 +5463,8 @@ \subsection*{Individual command functions}
54635463
\hfill \\
54645464
This command simulates a long range force between pairs of molecules. It uses loops over molecule pairs that's largely borrowed from \ttt{cmdradialdistribution}. Also, it keeps a list of molecules that have forces on them, which is in \ttt{cmd->v1}, used internally as \ttt{moleclist}. Each entry in this list includes the molecule serial number (on which the list is sorted), the molecule pointer, and a 4-dimensional vector of doubles. The first three dimensions are for the $x$, $y$, and $z$ components of the force on a molecule, and the fourth is 0 for molecules that were never visited during the last round of checks and 1 for molecules that were visited. Unvisited molecules get purged from this list, partly because those molecules might have gone away due to reactions.
54655465

5466+
The \ttt{scanportion} region scans over all molecules that fit the $species_1$ category. Each of these molecules is returned, one at a time, in \ttt{mptr}. This \ttt{mptr} is added to \ttt{moleclist}. The function then scans over all possible $species_2$ molecules that are within \ttt{rmax} distance of this molecule and checks to see if they interact. The \ttt{duplicate} test investigates whether \ttt{mptr2} is an instance of $species_1$ because if it is, then it's already in the \ttt{moleclist}, and if it's not then it needs to be put in that list, which is done. If it's put in the list, then that might shift the list by one, in which case \ttt{j} becomes incorrect; to address this, \ttt{j} is recomputed.
5467+
54665468
\item[\underline{Internal functions}]
54675469

54685470
\item[\ttt{void cmdv1free(cmdptr cmd);}]
@@ -6812,6 +6814,12 @@ \subsection*{Modifications for version 2.66 (not released yet)}
68126814
\item Added a test for Perl availability in bngrunBNGL, in smolbng.c.
68136815
\item Added smolGetSpecies function to libsmoldyn. I haven't tested it yet.
68146816

6817+
\subsection*{Modifications for version 2.67 (released 11/2/21)}
6818+
\item Dilawar fixed a typo in the filament code.
6819+
\item Fixed the \ttt{longrangeforce} command, where an index value could be off by one.
6820+
\item Jonathan Karr and Dilawar updated the Biosimulators links.
6821+
6822+
68156823
\end{itemize}
68166824

68176825

docs/Smoldyn/SmoldynManual.pdf

554 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)