From deecc34b16d37e004810f8fbcdd87f1f0b2c3fd4 Mon Sep 17 00:00:00 2001
From: whimsial <ai1v14@soton.ac.uk>
Date: Tue, 10 Jul 2018 14:37:10 +0100
Subject: [PATCH] Resolved issue with load direction and added comments to the
 code

---
 LoadCase/LoadsAndBCs.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/LoadCase/LoadsAndBCs.py b/LoadCase/LoadsAndBCs.py
index 5e72d4a..17fdf4e 100644
--- a/LoadCase/LoadsAndBCs.py
+++ b/LoadCase/LoadsAndBCs.py
@@ -27,8 +27,13 @@ def create_load(data, **kwargs):
     # Iterate through unique ipMT names
     mt_names = [sublist[0] for sublist in data]
     mt_names = set(mt_names)
-    i = 0
+    # Specify that the load is negative for all ipMTs that have even numbers and positive otherwise
     for mtname in mt_names:
+        if int(mtname[-1]) % 2 == 0:
+            load = -LoadVal
+        else:
+            load = LoadVal
+        # Locate the points to which loads are to be applied
         for sublist in data:
             if mtname == sublist[0]:
                 connector_end = sublist[3]
@@ -40,10 +45,7 @@ def create_load(data, **kwargs):
                 loadName = 'Load-' + connector_name + '-' + str(connector_end)
                 loadRegion = a.Set(vertices=loadPoint,
                                      name=loadName)
-                if i % 2 == 0:
-                    load = -LoadVal
-                else:
-                    load = LoadVal
+                # Apply loads
                 mdb.models[modelname].ConcentratedForce(name=loadName,
                                                         createStepName=StepName,
                                                         region=loadRegion,
@@ -51,7 +53,6 @@ def create_load(data, **kwargs):
                                                         distributionType=UNIFORM,
                                                         field='',
                                                         localCsys=None)
-        i += 1
 
     # ipMTnames = kwargs['ipMTnames']
     # StepName = kwargs['StepName']
-- 
GitLab