The hoard of clutter within someone's memories

Some of it is useful

Any AI version of Marie Kondo should just give up!

Now the data entry format is decided, the data needs to be read. So using the short XML file example given earlier, that data needs to be read using Java but first a conundrum. This is about to go all Bishop Berkeley, so here goes.

If a reaction force is zero, does it exist?

For a truss framework to be stable, there need to be rigid joints and possibly sliding joints which have restricted movement. There is a standard equation for two-dimensional truss frameworks which can be used to determine if a given framework is stable or not, this is the number of structural members added to the number of reaction forces minus double the number of joints which is often written as:

M+R - 2J

If the above equation results in an integer less than zero, the system is unstable and not solvable. If it is equal to zero, the system is statically determinate which means that it can be solved using relatively simple means. This is the standard framework given in basic exam examples. If it is greater than 0 then the system is statically indeterminate, which means it needs some more time, effort, and additional mathematics before it can be solved.

Rather than make things over-complex, I am going to decide and my answer is this: It does not matter!

The existence of the force may be in question but the existence of the restriction of displacement is not. Therefore I am going to think of the term R as a displacement restriction term and not a reaction force term. That way, there is no confusion, the equation is always valid and this enterprise will not grind to an indignified halt.

The following Java code reads the XML/dtd files and determines the two-dimensional framework stability:


import javax.xml.parsers.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import java.text.*;
public class TestXML
{
    public static void main(String[] args)
    {
    Document doc = getDocument("Test1.xml");
    Element root = doc.getDocumentElement();
    Element tElement = (Element)root.getElementsByTagName("title").item(0);
    String title = getTextValue(tElement).trim();
    System.out.println("The title is: "+title);
    Element jElement = (Element)root.getElementsByTagName("joints").item(0);
    NodeList numRigidJoints = jElement.getElementsByTagName("rigidjoint");
    NodeList numSlideXJoints = jElement.getElementsByTagName("slidexjoint");
    NodeList numSlideYJoints = jElement.getElementsByTagName("slideyjoint");
    NodeList numSimpleJoints = jElement.getElementsByTagName("simplejoint");
    int numJoints = numRigidJoints.getLength()+numSlideXJoints.getLength()
    +numSlideYJoints.getLength()+numSimpleJoints.getLength();
    System.out.println("The number of joints are: "+numJoints);
    Element smElement = (Element)root.getElementsByTagName("strmems").item(0);
    NodeList numStrMems = smElement.getElementsByTagName("strmem");
    int numofStrMems = numStrMems.getLength();
    System.out.println("The number of structural members are: "+numofStrMems);
    int numofDispRestrs = (2*numRigidJoints.getLength())
    +(numSlideXJoints.getLength())+(numSlideYJoints.getLength());
    System.out.println("The number of displacement restrictions are: "+numofDispRestrs);
    int Stab = (numofDispRestrs+numofStrMems)-(2*numJoints);
    if (Stab<0){
            System.out.println("This system is unstable, it cannot be solved!");
    } else if (Stab==0){
            System.out.println("This system is statically determinate.");
    } else {
            System.out.println("This system is statically indeterminate,
    may require some time to solve!");
    }
    }
    private static Document getDocument(String name)
    {
    try
    {
    DocumentBuilderFactory framework =
    DocumentBuilderFactory.newInstance();
    framework.setIgnoringComments(true);
    framework.setIgnoringElementContentWhitespace(true);
    framework.setValidating(true);
    DocumentBuilder builder =
    framework.newDocumentBuilder();
    return builder.parse(new InputSource(name));
    }
    catch (Exception e)
    {
    System.out.println(e.getMessage());
    }
    return null;
    }
    private static String getTextValue(Node n)
    {
    return n.getFirstChild().getNodeValue();
    }
}

There are a few imports with asterisks, which means import everything which is a bad habit in general but I am going to leave it for the moment because this work is still ongoing. Once all the specific imports are known then change the import parameters after the work is finished. That way, things are less likely to bork!

You may also note that the first import has the term javax, this is not a standard core part of Java and needs to be downloaded separately. Javax adds additional functionality, in this case it is required to parse the XML files.

In the getDocument class there is a line which states framework.setValidating(true); which means that a valid dtd file needs to be present with the XML file. If it is not there or it is not correct, then a lot of horrible and incomprehensible error messages will result. If you are having trouble with the dtd file, set the parameter to false until you get things working.

Next is to combine this work with the previous work of creating the required objects. Then work can turn to solving.

About

This is where I place the very basic notes on programming from those starting at the very beginning using Linux or similar operating systems. It's set up to be understood by everyone. If you have an opinion as to how this page is done, then you are already and intermediate or advanced programmer and I don't care!