Loading
/custom-emojis/emojis/contour-map.png
Templates
📚
Articles & Resources
📖
Guides & Support
🌵
CalcTree
Estados de Vigas de Concreto
Bust Common Myths About Java Programming
Loading
/custom-emojis/emojis/calculator.png
Tensile Strength and Capacity Control of the W-Shape Sections According to AISC 360-16
Loading
/custom-emojis/emojis/calculator.png
Concrete Cylinder Strength Vs Cube Strength
Loading
/custom-emojis/emojis/calculator.png
Earthquake Design Action Calculation
Sıvılaşma Verileri Tablosu
Loading
/custom-emojis/emojis/rc-beam.png
Concrete Column Designer to AS3600
EM Wave Propagation Calculator
section properties with units
Forward Kinematics of Robotic Arm with 6 Degrees of Freedom
İKSA YAPILARI PROJELENDİRME HİZMET BEDELİ (2024)
GEOTEKNİK RAPOR (EK-B) ASGARİ HİZMET BEDELİ (2024)
ZEMİN İYİLEŞTİRME/DERİN TEMEL PROJELENDİRME ASGARİ HİZMET BEDELİ (2024) (İMO)
🚀
Projectile motion
Loading
/custom-emojis/emojis/bending-moment.png
Dezi et. al (2010)
🤾
Projectile motion
Enhancing Civil Engineering Calculations in Chatbots with CalcTree API Integration's banner
🧠

Enhancing Civil Engineering Calculations in Chatbots with CalcTree API Integration

Artificial intelligence has the potential to revolutionise how we design everything.
Imagine having an AI assistant to create engineering calculation workflows. The AI assistant could be a conversational chatbot like Google Gemini or ChatGPT. Unfortunately however, these chatbots are not currently safe for engineering tasks as they can produce erroneous calculation answers with high confidence, which can be misleading.
CalcTree plays a pivotal role here. CalcTree is a cloud-based platform that allows users to define engineering and calculation logic in languages they're familiar with (Python, spreadsheets, no-code). CalcTree and LLMs can be strung together using their APIs, and so the accuracy of engineering calculations from CalcTree is combined with the power of an LLM.
In this article, we discuss the technical details of connecting CalcTree's API with Google Gemini, and we demonstrate how this was used to obtain an accurate result for a bearing capacity calculation.

What are LLMs?



Why are ChatGPT and Google Gemini bad at calculations, while it is very good at other stuff?

ChatGPT and Google Gemini are language models, not computational models. This is very important as the model approaches the input problems as language problems rather than mathematical ones. When we ask a simple problem such as “10 + 10”, it will return an answer of "20" because, from all the information it’s been trained on, 20 was determined to be the most preferred response based on feedback.
We ran a few tests on ChatGPT by providing engineering-related prompts to see how well it performs. Check out the experiment here. In summary, ChatGPT does an impressive job of explaining engineering concepts to us. It can follow general calculation guidelines and understand procedures, though it is unable to make judgments when it comes to the correct usage of some input data.

Setting up Google Gemini with CalcTree's API

The below snippets are from a Google Colab Notebook. You can access the full script in the code source of this page.

Step 1: Obtain APIs

Firstly. we need to obtain:
  1. CalcTree API key and page ID of the calculation template. This CalcTree API guide talks us through how to do this.
  2. Gemini API key from your Google AI Studio.

Step 2: Install the necessary packages and classes

Here are the necessary packages:

Here are the necessary classes:


Step 3: Create a tool

We create a tool which is a function that is decorated by a LangChain tool class. LangChain is a programming framework to help develop code using language models. The LangChain tool class uses the user prompt as the parameters to be passed onto the function.



Step 4: Create a user prompt and output


We can understand how the parameters are represented with the function name for the tool created.



Results

We compare the results of the ultimate bearing capacity,

given the following inputs:
  1. Footing width,
    
    
  2. Footing depth,
    
    
  3. Soil cohesion,
    
    
  4. Soil friction angle,
    
    
  5. Soil unit weight,
    
    
  6. Load inclination,
    
    

The comparison below shows the result from using Google Gemini with CalcTree's API is the same as the CalcTree template itself, and the result from using Google Gemini or ChatGPT-4 alone is not accurate.

Let's do this calculation by hand to validate our results. The ultimate bearing capacity of a shallow footing is given by:

qu=scNcdcicc+sqNqdqiqγD+12γBsγNγdγiγq_u=s_cN_c d_ci_cc'+s_qN_qd_qi_q\gamma D+\frac{1}{2}\gamma Bs_\gamma N_\gamma d_\gamma i_\gamma
Where:
  1. 
    
    
  2. 
    
    
  3. 
    
    
  4. 
    
    
  5. 
    
    
  6. 
    
    
  7. 
    
    
  8. 
    
    
  9. 
    
    

And so, we have:

qu=scNcdcicc+sqNqdqiqγD+12γBsγNγdγiγ=2.61×55.63×1.28×0.75×40+1.80×42.92×1.14×0.46×11×7+12×11×10×1.80×53.27×1.14×0.46=11,461 kPaq_u=s_cN_c d_ci_cc'+s_qN_qd_qi_q\gamma D+\frac{1}{2}\gamma Bs_\gamma N_\gamma d_\gamma i_\gamma\\=2.61 \times 55.63\times1.28\times0.75\times40\\+1.80 \times 42.92\times1.14\times0.46\times11\times7\\+\frac{1}{2}\times11\times10\times1.80 \times 53.27\times1.14\times0.46 \\= 11,461 \space kPa
This is

given rounding errors.

Conclusion

In conclusion, the integration of the CalcTree API with a conversational chatbot like Google Gemini significantly enhances the accuracy and reliability of engineering calculations. Traditional LLMs, despite their advanced capabilities in language understanding and generation, are limited in their ability to perform accurate engineering calculations.
CalcTree helps bridge this gap because it makes engineering data accessible and interpretable by systems designed for AI training, via its API.
By leveraging CalcTree's API, LLMs can communicate with these templates, thus combining the conversational ease and flexibility of LLMs with the rich knowledge of engineering computations.

Acknowledgments

This article was created in collaboration with Kamal Samaila.

Related Resources

  1. The Rise of Generative AI And Its Challenges
  2. ChatGPT Challenges in Engineering Data Calculation

CalcTree

CalcTree, the app you're reading this one is a calculation management platform. You can sign-up and build hosted, shareable web apps (complete with an API and a web publishing module) with tools like Python and Spreadsheets. Learn more here!