Python Forum
Design of scantling calculation program. Newbie
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Design of scantling calculation program. Newbie
#1
Hi there,

I have basic coding knowledge and I'm trying to write my first project to hone out my skills. I've done plenty of tutorials, have a grasp on the basic syntax and logic (variables, loops, conditionals, functions).

The real meat and hardest part of building a app/program seems to me how to organize program on the macro level, desing patterns and such. How you choose to store your data, how you choose to break up your functions, etc.

For my first project I'm want to write a program that does scantling calculations for boats based on a set of rules published a class society (DNV-GL). Usually I use a spreadsheet for such calculations, but they end being rather huge and cubersome to work with.

The flow of data goes something like this:

Inputs:
Vessel parameters (lenght, weight, speed, etc.)
Strucutral elements parameters. There are 2 main types: panels and stiffeners. Each is definied by a set of parameters (spam, load width, boundry conditions, material, position in vessel, etc.)
Materials. The structure is made of composite materials. A composite laminate is made up of several individual lamina stacked in a particluar order, which have their on elastic properties. These are in turn used to calculate the elastic properties of a given laminate.

Calculated values:
Vessel accelerations - calcutaed based on vessel parameters
Pressures. Each structural element has a pressure acting on it, which is calculated based the vessels parameters, the vessels accelerations and the panel or sftiffener parameters.
Plates and stiffeners reactions, that is, bending moments and shear forces. These are calculated with the given pressures acting on the given structural element and its parameters.
Strucural responses - stress, strains and displacements. With the given structural element reactions, the material elastic properties and parameters of the element the resulting strains, stresses and displacments are calculated.
Comparison of stucutral responses with allowed values. The final step is comparing the calcuted strucutral response with allowed values and outputing the results to the user.

I'm using a spreadsheet with pyexcel for input/output.

My main question so far is how to treat my data. I could use dictionaries for the different data strucutres (vessel, strucural elements, pressures, reactions, strucutral responses, etc.) and functions for the calculations. Or I could use classes and class instances to represent the same data and methods for the calculations.

What be the main advantages/disavantages of each aproach?

Thanks a lot
Reply
#2
Use class instances. Dictionaries are just containers, class instances are containers plus flexible behavior. That's why OOP was invented. Don't reinvent a wheel by following paths that were discovered forty years ago.
Reply
#3
Thanls Gribouillis, that was my intuition also
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  High level Python program architectural design question - decoration for multiple ent yahbai 0 1,747 Jan-16-2020, 08:30 PM
Last Post: yahbai

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020