From c608df82240e4f9fd46313c6dc02bffb099da2ce Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Mon, 11 Oct 2021 12:23:22 +0100
Subject: [PATCH] fix issue where there's no M1, M2 in the vb=1 log if
 multiplicity isn't set

---
 binarycpython/utils/distribution_functions.py |  2 +-
 binarycpython/utils/grid.py                   | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/binarycpython/utils/distribution_functions.py b/binarycpython/utils/distribution_functions.py
index 9fbb263cb..92e2ea41a 100644
--- a/binarycpython/utils/distribution_functions.py
+++ b/binarycpython/utils/distribution_functions.py
@@ -385,7 +385,7 @@ def gaussian(
     gmax: Union[int, float],
 ) -> Union[int, float]:
     """
-    Gaussian distribution function. used for e..g Duquennoy + Mayor 1991
+    Gaussian distribution function. used for e.g. Duquennoy + Mayor 1991
 
     Args:
         x: location at which to evaluate the distribution
diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 5d096f4f7..5eb79465c 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -4525,12 +4525,22 @@ eccentricity3=0
 
         # make a string to describe the system e.g. M1, M2, etc.
         system_string = ""
+
+        # use the multiplicity if given
         if "multiplicity" in system_dict:
-            for i in range(system_dict["multiplicity"]):
-                i1 = str(i + 1)
+            nmult = system_dict["multiplicity"]
+        else:
+            nmult = 4
+
+        # masses
+        for i in range(nmult):
+            i1 = str(i + 1)
+            if "M_"+i1 in system_dict:
                 system_string += (
                     "M{}=".format(i1) + format_number(system_dict["M_" + i1]) + " "
                 )
+
+        # separation and orbital period
         if "separation" in system_dict:
             system_string += "a=" + format_number(system_dict["separation"])
         if "orbital_period" in system_dict:
-- 
GitLab