Giter VIP home page Giter VIP logo

geolib's People

Contributors

anoordam avatar breinbaas avatar carloslubbers avatar carsopre avatar dependabot[bot] avatar elenismyrniou avatar evetion avatar ic144 avatar johnbokma avatar jwdobken avatar maarten-betman avatar maartenbw avatar markvanderkrogt avatar martinapippi avatar matthiashauthdeltares avatar peter-van-tol avatar ringovdvelden avatar svandermeer avatar virginietrompille avatar wfaustmann avatar yurnih avatar zantdelta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geolib's Issues

Parse DFoundationsModel results in an AttributeError: type object 'list' has no attribute '_special'

When parsing a DFoundations result file with the GEOLib I get an AttributeError. I attach the file to this issue. The file is created with the correct version, as stated in the documentation.

Steps to reproduce

!pip install d-geolib==0.1.6

from geolib import DFoundationsModel

ds = DFoundationsModel()
ds.parse(file)

Relevant logs and/or screenshots

File /opt/conda/lib/python3.9/site-packages/geolib/models/base_model.py:149, in BaseModel.parse(self, filename)
    147 self.filename = filename
    148 # self.datastructure = None
--> 149 self.datastructure = self.parser_provider_type().parse(filename)
    150 return self.datastructure

File /opt/conda/lib/python3.9/site-packages/geolib/models/parsers.py:61, in BaseParserProvider.parse(self, filename)
     59 for parser in self.output_parsers:
     60     if parser.can_parse(filename):
---> 61         return parser.parse(filename)
     62 raise ValueError(f"Unknown extension {filename.suffix} for {self.parser_name}.")

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:1147, in DSerieParser.parse(self, filename)
   1144 logger.debug(f"Parsing {filename}")
   1146 with open(filename) as io:
-> 1147     datastructure = self.dserie_structure.parse_text(io.read())
   1149 return datastructure

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:158, in DSeriesStructure.parse_text(cls, data)
    152 """Creates a DSeriesStructure using the concrete parser.
    153 
    154 Arguments:
    155     data {str} -- Data to parse.
    156 """
    157 parsed_structure = DSerieParser.parse_group_as_dict(data)
--> 158 return cls(**parsed_structure)

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:98, in DSeriesStructure.__init__(self, *args, **kwargs)
     96 if hasattr(fieldtype, "is_parseable") and fieldtype.is_parseable():
     97     logger.debug(f"Changed {field} to {fieldtype}")
---> 98     kwargs[field] = fieldtype.parse_text(body)
     99 else:
    100     if DataClass in fieldtype.__mro__:

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:158, in DSeriesStructure.parse_text(cls, data)
    152 """Creates a DSeriesStructure using the concrete parser.
    153 
    154 Arguments:
    155     data {str} -- Data to parse.
    156 """
    157 parsed_structure = DSerieParser.parse_group_as_dict(data)
--> 158 return cls(**parsed_structure)

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:98, in DSeriesStructure.__init__(self, *args, **kwargs)
     96 if hasattr(fieldtype, "is_parseable") and fieldtype.is_parseable():
     97     logger.debug(f"Changed {field} to {fieldtype}")
---> 98     kwargs[field] = fieldtype.parse_text(body)
     99 else:
    100     if DataClass in fieldtype.__mro__:

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:158, in DSeriesStructure.parse_text(cls, data)
    152 """Creates a DSeriesStructure using the concrete parser.
    153 
    154 Arguments:
    155     data {str} -- Data to parse.
    156 """
    157 parsed_structure = DSerieParser.parse_group_as_dict(data)
--> 158 return cls(**parsed_structure)

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:98, in DSeriesStructure.__init__(self, *args, **kwargs)
     96 if hasattr(fieldtype, "is_parseable") and fieldtype.is_parseable():
     97     logger.debug(f"Changed {field} to {fieldtype}")
---> 98     kwargs[field] = fieldtype.parse_text(body)
     99 else:
    100     if DataClass in fieldtype.__mro__:

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:701, in DSeriesStructureCollection.parse_text(cls, text)
    696     raise ValueError(
    697         f"Expected {number_of_groups} groups, but parsed {len(parsed_groups)}."
    698     )
    700 parsed_collection = {fields[0][0]: parsed_groups}
--> 701 return cls(**parsed_collection)

File /opt/conda/lib/python3.9/site-packages/geolib/models/dseries_parser.py:119, in DSeriesStructure.__init__(self, *args, **kwargs)
    117 # And then the list
    118 if is_list(fieldtype):
--> 119     fieldtype, *_ = get_args(fieldtype)
    121     # Check whether we can parse and if so, parse the strings
    122     if hasattr(fieldtype, "is_parseable") and fieldtype.is_parseable():

File /opt/conda/lib/python3.9/site-packages/geolib/models/utils.py:16, in get_args(tp)
      6 def get_args(tp):
      7     """Get type arguments with all substitutions performed.
      8     For unions, basic simplifications used by Union constructor are performed.
      9     Examples::
   (...)
     14         get_args(Callable[[], T][int]) == ([], int)
     15     """
---> 16     if isinstance(tp, (_GenericAlias, _SpecialForm)) and not tp._special:
     17         res = tp.__args__
     18         if tp.__origin__ is collections.abc.Callable and res[0] is not Ellipsis:

File /opt/conda/lib/python3.9/typing.py:705, in _BaseGenericAlias.__getattr__(self, attr)
    701 def __getattr__(self, attr):
    702     # We are careful for copy and pickle.
    703     # Also for simplicity we just don't relay all dunder names
    704     if '__origin__' in self.__dict__ and not _is_dunder(attr):
--> 705         return getattr(self.__origin__, attr)
    706     raise AttributeError(attr)

AttributeError: type object 'list' has no attribute '_special'

File

bm1-1a.zip

FYI: @martinapippi

Remove Earthquake from DSheetPiling code

Remove Earthquake from DSheetPiling python code and documentation because Earthquake was not used in calculation (for evaluation only) and it is now completely removed from DSheetPiling code itself.
Note that there is also an Earthquake in DStability (that must stay).

Can't get D-Settlement console to run

I have placed the D-Settlement console in a folder (which is written in an *.env file), but everytime I try to execute the D-Settlement model, a window opens with the following error message:
"License not granted
Module(s) not found in the license file or borrowed modules, or license file not found.
Batch processing not allowed."

How to solve this?

allow dynamic settings for D-Stability console

As suggested in the docs, I found it really helpful to set up the path of the DStability console in a dynamic way:

dm.meta.console_folder = Path("other_location")  # has to exist!

However , this is no longer possible because the console path can no longer be set:

print(model.console_path)  # DStabilityConsole\D-Stability Console.exe
model.console_path = Path("other_location")  # crash :(

Note also that the meta attribute no longer exists too.

DFoundations with new version

Previously when i ran my code with Version 0.2.0 there were no issues, now when i run my code with Version 1.0.1 i get the following problem:
ValueError: Got more fields than defined on model DFoundationsStructure:
parser has {'calculation_warnings'} fields and
model has set() fields not set.

D-geolib limits pile name length to 10 characters

We noticed that d-geolib limits the pile_name parameter length in classes like TensionPileLocation or TensionRectangularPile to 10 characters. Dfoundations it self does not seem to have this limit. Can this limit be removed or upgraded to atleast the dfoundations limit if there even is one?

[DSheet] Missing feature for setting vertical balance parameters

There is no method for setting the maximum point resistance and xi factor that are needed for calculation the vertical balance.

The current work-around is setting the vertical balance properties directly as a string via model.datastructure.input_data.vertical_balance.

I've created functionality for setting these parameters but I think I need to be assigned as a contributer in order to create a new branch. Could you add me as a contributer?

Regards,
Daniël Kentrop

image

Older DStability stix files cannot be read

Reading older stix files will generate 'ValueError("Can't listdir a file")'

Short solution is to manually open the file in DStability and save it again but this would be tedious if you have a lot of old files (which people probably have).

`D:\Documents\Development\Python\ontgrondingskuilen.env\Lib\site-packages\shapely\set_operations.py:133: RuntimeWarning: invalid value encountered in intersection
return lib.intersection(a, b, **kwargs)
Traceback (most recent call last):

File "D:\Documents\Development\Github\GEOLib\geolib\models\dstability\dstability_parserprovider.py", line 93, in parse
ds = super().parse(path)
^^^^^^^^^^^^^^^^^^^
File "D:\Documents\Development\Github\GEOLib\geolib\models\dstability\dstability_parserprovider.py", line 37, in parse
ds[field] = self.__parse_folder(element_type, filepath / "")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Documents\Development\Github\GEOLib\geolib\models\dstability\dstability_parserprovider.py", line 53, in _parse_folder
files = list(folder.iterdir())
^^^^^^^^^^^^^^^^
File "D:\Documents\Development\Python\ontgrondingskuilen.env\Lib\site-packages\zipp_init
.py", line 347, in iterdir
raise ValueError("Can't listdir a file")
ValueError: Can't listdir a file`

Path to DGeoFlow console

There seems to be an minor mistake in the path to DGeoFlow console, which is not inline with an installed version of DGeoFlow. Using a geolib.env file and a MetaData class to set the path to the console, running DGeoFlow should be possible. However, the folder "DGeoFlowConsole" is not present after installing DGeoFlow.

geolib/models/dgeoflow/dgeoflow_model.py line 58 and 59:

    def console_path(self) -> Path:
        return Path("DGeoFlowConsole/DGeoFlow Console.exe")

Propose to change the path to return Path("DGeoFlow Console.exe")

[DStability] Bug in sorting of stages if no. stages >10

A d-stability stix-file is parsed in dstability_parserprovider.py. The order of the stages is maintained by sorting the file names. However if there are 11 or more stages then the stage order gets mixed-up because when sorting strings the '10' will be placed after '1'.

DStability will not open geolib generated input files

The current version of D-Stability (2023.01) generates an error with geolib generated stix files. The error is;

Project could not be migrated to the latest version Error converting value "MohrCoulombAdvanced to type

ModulusSubgradeReaction enum reversed

Hello,

I noticed a bug in GEOLIB, when using the Soil.subgrade_reaction_parameters.modulus_subgrade_reaction_type setting the resulting setting in the .shi input file is reversed.
So when ModulusSubgradeReaction.MENARD is chosen, this results in the MANUAL option being set in the input file and vice versa.

D-Foundations set console path

I have been trying to set the console path for D-Foundations. It looks like the current documentation is a bit outdated there, but the problem i have is that i have only been able to set the console_folder:

df.set_meta_property("console_folder",Path(r"C:\Program Files (x86)\Deltares\D-Foundations 23.1.1"))

This means that Geolib will look in the following folder for the executable:
C:\Program Files (x86)\Deltares\D-Foundations 23.1.1\DFoundations\DFoundations.exe

I thought this might be fixed by adjusting the custom_console_folder, but i can't seem to set this. Now i have to add a folder and copy the executable, which isn't a very elegant work-around.

[DSheetPiling] The wall types Wooden Sheet Piling and Diaphragm Wall are not correctly defined

For wooden sheet piling, a Plastic calculation should not be possible and the parameter WoodenSheetPiling should be True.
For diaphragm wall, an Elastic calculation should not be possible and the parameter DiepwandCalculation should be True.

Moreover, the test test_run_sheet_model_acceptance_different_calculation_types_wooden_sheet_pile uses
modeltype = SheetModelType
instead of
modeltype = WoodenSheetPileModelType

Idem for test test_run_sheet_model_acceptance_different_calculation_types_diaphragm_wall.
It uses
modeltype = SheetModelType
instead of
modeltype = DiaphragmModelType

And finally, for ModelType 3 choices are possible in python script (SHEET_PILING=0, SINGLE_PILE=1 and DIAPHRAGM_WALL=2) but in the console only 0 and 1 are possible. So remove DIAPHRAGM_WALL and rename SHEET_PILING by WALL.

2024 DStability changes

Creating a DStability model and then trying to calculate it using 2024.01 results in the following error;

Output file generated but parsing of ... 34-1_0.45-0.81_0.stix failed.

pydantic.error_wrappers.ValidationError: 2 validation errors for UpliftVanParticleSwarmResult
ResultThreshold
  extra fields not permitted (type=value_error.extra)
SlipPlaneResults
  extra fields not permitted (type=value_error.extra)

This is due to missing fields in the geolib code.

D-Stability: parsing error with files generated from desktop

I generated an empty file from scratch (desktop D-Stability 2022.01.2) and tried to parse it with GEOLib. The default soils Id=2 and Id=11 can't be parsed properly and lead to pydantic ValidationErrors. I double-checked the variables and they are all positive in the .stix file so I am a bit puzzled by this error.

errorGEOLIB

Parsing results of D-SheetPiling

I am now working on parsing results from D-Sheet Piling V23. However, the structure has changed since last time i used it. One big issue i have is that in the data the names of the phases are impossible to find. I would suggest to add the name of a phase to the results class, it's a small addition but for tracking results it's a big improvement. For now i would be helped a lot if you can point me to where i can find the stagenames in the serialized file.

Issue(DStability): Soil visualizations change after geolib.models.DStabilityModel().execute()

Version
0.2.0

Issue:
After creating a model using GEOlib, going through serialization and then execution of said model, the soil visualizations are (seemingly) all reset to default and/or made equal to one visualization. This behaviour does not happen when geolib.models.DStabilityModel().execute() is skipped, see the attached images.

Serialized model opened in D-Stability excluding running geolib.models.DStabilityModel().execute()
image

Serialized model opened in D-Stability including running geolib.models.DStabilityModel().execute()
image

Steps to Reproduce

  1. Set up a DStability-model using GEOLib.
  2. geolib.models.DStabilityModel().serialize() the created model.
  3. Check the soil visualizations.
  4. geolib.models.DStabilityModel().execute() the created model.
  5. Check the soil visualizations.
  6. Compare output of steps 2 and 4.

BUG: pre-stress value of 0.1 is always applied to Anchor in DSheetPiling

Problem encountered

Whenever adding a Anchor to a DSheetPilingModel a default value of 0.1 is always added as pre-stress.
This is not only an unexpected behaviour but can lead to wrong results since whenever a pre stress is applied the anchor is calculated as a force and not as a spring (See DSheetPiling manual):
MicrosoftTeams-image

How to reproduce

from geolib import DSheetPilingModel
from geolib.geometry import Point
from geolib.models.dsheetpiling.calculation_options import PartialFactorCalculationType
from geolib.models.dsheetpiling.calculation_options import VerifyCalculationOptions
from geolib.models.dsheetpiling.dsheetpiling_model import SheetModelType
from geolib.models.dsheetpiling.settings import CalculationType
from geolib.models.dsheetpiling.settings import LateralEarthPressureMethod
from geolib.models.dsheetpiling.settings import LateralEarthPressureMethodStage
from geolib.models.dsheetpiling.settings import PassiveSide
from geolib.models.dsheetpiling.settings import Side
from geolib.models.dsheetpiling.settings import VerifyType
from geolib.models.dsheetpiling.surface import Surface
from geolib.models.dsheetpiling.water_level import WaterLevel
from geolib.models.dsheetpiling.supports import Anchor

surface_line_points_left = [Point(x=0, z=0), Point(x=20, z=0)]
surface_line_points_right = [Point(x=0, z=-5), Point(x=20, z=-5)]
water_level = -6
dsheet_model = DSheetPilingModel()
dsheet_model.set_model(
    SheetModelType(
        method=LateralEarthPressureMethod.C_PHI_DELTA,
        check_vertical_balance=False,
        trildens_calculation=False,  # settlement by vibration
        verification=True,
        # reliability_analysis=False, not allowed by pydantic validation ?!
        elastic_calculation=True,
    )
)
calc_options = VerifyCalculationOptions(
    input_calculation_type=CalculationType.VERIFY_SHEETPILING,
    verify_type=VerifyType.EC7NL,
    ec7_nl_method=PartialFactorCalculationType.METHODB,
    ec7_nad_nl_overall_stability=False,
)
dsheet_model.set_calculation_options(calculation_options=calc_options)
dsheet_model.add_stage(
    name="Initialized stage",
    passive_side=PassiveSide.LEFT,
    method_left=LateralEarthPressureMethodStage.C_PHI_DELTA,
    method_right=LateralEarthPressureMethodStage.C_PHI_DELTA,
)
dsheet_model.add_surface(
    surface=Surface(name="Initialized surface", points=surface_line_points_left),
    side=Side.LEFT,
    stage_id=dsheet_model.current_stage,
)
dsheet_model.add_surface(
    surface=Surface(name="Initialized surface", points=surface_line_points_right),
    side=Side.RIGHT,
    stage_id=dsheet_model.current_stage,
)
dsheet_model.add_head_line(
    water_level=WaterLevel(name="Test water level", level=water_level),
    side=Side.BOTH,
    stage_id=dsheet_model.current_stage,
)
dsheet_model.add_anchor_or_strut(Anchor(
            name="Anchor",
            level=-6), stage_id=)
dsheet_model.serialize("test_anchor_prestress.shi")

image

Possible fix

Change default prestress value to None and change template to:


{% for anchor in stage.anchors %}
{{ "%10d"|format(loop.index) }}       {{ anchor.pre_stress if not None}} {{ anchor.name }}
{% endfor %}

DStability input files with NaN values cannot be parsed

Originally reported by Thijs Damsma

Somehow DStability files created with the desktop application can have NaN values for certain fields (I didn’t create them and don’t know exactly how this happened, but I do need to parse them). If one tries to load these in geolib these then the input is rejected as NaN is not a valid value for those fields. I’m guessing NaN should be interpreted as “not set”, so this can easily be solved by ignoring all fields with nan values when parsing the input.

Feature: Add routine to remove a layer

D-Stability & D-Geo Flow models currently offer an add_layer method, but no remove_layer method.

When removing a layer, the data model needs to be cleaned up. References to the layer need to be removed.

D-Stability:

  • Soil layer
  • Consolidations
  • Waternet creator aquifer layers

D-Geo Flow:

  • Soil layer
  • Mesh properties

This issue is can be developed by the community if they deem this useful

Bug in serialization of "imaginary surface layer" in DSettlement calculation options

To reproduce follow the steps of Tutorial DSettlement and at the end add the following:
dm.set_any_calculation_options(is_imaginary_surface=True, imaginary_surface_layer=2, is_submerging=True)

Open the created input file (Tutorial.sli) and go to block [CALCULATION OPTIONS].
You see the following:
[CALCULATION OPTIONS]
0 : Precon. pressure within a layer = CONSTANT_NO_CORRECTION
1 : Imaginary surface = TRUE
: Imaginary surface layer =
1 : Submerging = TRUE

But you expect:
[CALCULATION OPTIONS]
0 : Precon. pressure within a layer = Constant (constant in the layers)
1 : Imaginary surface = TRUE
2 = Imaginary surface layer
1 : Submerging = TRUE

Cannot execute DStability model

I tried following the tutorial as given in https://deltares.github.io/GEOLib/latest/community/tutorial_dstability_general.html,
However, I always get the following error:

Error: Project could not be opened.
Error converting value "MohrCoulombAdvanced" to type 'Components.Persistence.Stability.Data.PersistableShearStrengthModelType'. Path 'Soils[0].ShearStrengthModelTypeAbovePhreaticLevel', line 10, position 77.
at DGeoSuite.Components.Persistence.Archive.ArchiveSource.Read(ReadableEntity entity)
at Components.Persistence.Stability.Archive.PersistableDataModelReader.ReadSoils()
at Components.Persistence.Stability.Archive.PersistableDataModelReader.Read()
at Application.Common.ProjectFileHelper.PersistableReader.Read(String filePath)
at DGeoSuite.Components.Persistence.FilePersister.OpenFromFile[T](IPersistableReader`1 reader, String filePath)

I use d-geolib v1.3.3 and DStability version 2023.01
Any idea on what causes this error? I attached the generated stix file.
geolib_trial.zip

[DStability] the output is only parsed for the current stage

Current behavior

Let's suppose a .stix file made of 2 stages, each of them with their own result and factor of safety.

dm = DStabilityModel()
dm.parse(stix_file)
output = dm.output  # <class 'geolib.models.dstability.internal.UpliftVanParticleSwarmResult'>

I can only retrieve the result from the latest stage from output.

Expected behavior

dm.output should be of type list and return the results of all stages

Missing feature: tree loads

Although the TreeLoad class exists in the file loads.py, I am still unable to instantiate a tree load because it is still an abstract class (see below). Will the tree load feature be added soon? Thanks in advance.

TypeError: Can't instantiate abstract class TreeLoad with abstract method to_internal_datastructure

[DStability] Can't set the stochastic properties of a pop parameter

Current behavior:

There is a bug with the addition of a state point as a probabilistic variable. The method below adds a state point with a pop value=29 but the toggle IsProbabilistic is still turned off and the mean & std are not filled in

add_state_point(
                state_point=DStabilityStatePoint(
                    layer_id=pop_point["layer_id"],
                    point=Point(x=0, z=0),
                    is_probabilistic=True,
                    stress=DStabilityStress(pop=29,
                                            stochastic_parameter=PersistableStochasticParameter(
                                                IsProbabilistic=True,
                                                Mean=43,
                                                StandardDeviation=10),
                                            ),
                ),
                stage_id=stage_id,

Expected behavior:

The stochastic parameters should be filled in if provided

Changing existing model using Geolib

I'm trying to use Geolib to modify existing DSheetPilling model:
model = DSheetPilingModel()
model.parse(Path('tutorial.shi'))

tutorial.shi is based on the tutorial https://deltares.github.io/GEOLib/latest/community/tutorial_dsheetpiling.html

However, when I want to add new construction stage, the existing one in the model is overwritten.
new_stage_id = model.add_stage( name="Newer Stage", passive_side=PassiveSide.DSHEETPILING_DETERMINED, method_left=LateralEarthPressureMethodStage.KA_KO_KP, method_right=LateralEarthPressureMethodStage.KA_KO_KP, pile_top_displacement=0.02, )

I found out that construction stages (model.datastructure.input_data.construction_stages) are of the type str
Is there a better way of working with existing models?

Link download portal no longer works

Hi, apparently the download portal has been changed. Firstly this means the link in the docs doesn't work. Secondly, i can't find the consoles anywhere on the download portal. My current set of consoles results in errors with parsing.

console_path for d-sheet console

In the D-Sheet model (dsheetpiling_model.py) the console path is set to:

return Path("DSheetPiling/DSheetPiling.exe")

However, the default directory for installation of the DSheet Piling v23 consoles/executables is different. These are installed with

D-Sheet Piling 23.1.1/DSheetPiling.exe

Temporary workaround is now changing this line in the installed geolib module.

Is this a bug, or can the actual folder of the executables be specified in the geolib.env file as well? According to the documentation (and code) it is to be excpected in the folder DSheetPiling/ instead of D-Sheet Piling 23.1.1/

Soiltype undrained_parameters.undrained_shear_strength not optional

According to the documentation, the undrained_parameters parameter of Soil is optional. However, when adding Soil to a DFoundationsModel via model.add_soil(soil), python crashes because a field is missing. The missing field is undrained_parameters.undrained_shear_strength. Setting this to a random value makes it work.. I expect this option to be optional because it is not always needed in the calculation.

Steps to reproduce:

from geolib.models.dfoundations.dfoundations_model import DFoundationsModel
from geolib.soils.soil import Soil, SoilType

SOIL_PARAMETERS = [
    {'materiaal': 'Onbekend materiaal', "unsat": 0.0, "sat": 0.0, "phi": 0.0, "soiltype": SoilType.GRAVEL},
    {'materiaal': 'Grond, fijn korrelig', "unsat": 18.0, "sat": 20.0, "phi": 25.0, "soiltype": SoilType.SAND},
    {'materiaal': 'Veen', "unsat": 12.0, "sat": 12.0, "phi": 15.0, "soiltype": SoilType.PEAT},
    {'materiaal': 'Klei, zwk siltig-siltig', "unsat": 15.0, "sat": 15.0, "phi": 20.0, "soiltype": SoilType.CLAY},
    {'materiaal': 'Klei, siltig/leem', "unsat": 16.5, "sat": 16.5, "phi": 25.0, "soiltype": SoilType.CLAY},
    {'materiaal': 'Zand, siltig tot leem', "unsat": 17.0, "sat": 19.0, "phi": 27.5, "soiltype": SoilType.SAND},
    {'materiaal': 'Zand, zwk siltig-siltig', "unsat": 18.0, "sat": 20.0, "phi": 30, "soiltype": SoilType.SAND},
    {'materiaal': 'Zand, zand tot grindig', "unsat": 18.0, "sat": 20.0, "phi": 32.5, "soiltype": SoilType.GRAVEL},
    {'materiaal': 'Zand, vastzand, kleiig', "unsat": 18.0, "sat": 20.0, "phi": 30.0, "soiltype": SoilType.SAND},
    {'materiaal': 'Grond, zeer stijf', "unsat": 18.0, "sat": 20.0, "phi": 30.0, "soiltype": SoilType.SAND}
]

model = DFoundationsModel()

for soil in SOIL_PARAMETERS:
    soil_type = Soil()
    soil_type.name = soil["materiaal"]
    soil_type.soil_type_nl = soil["soiltype"]
    soil_type.mohr_coulomb_parameters.friction_angle = soil["phi"]
    soil_type.soil_weight_parameters.saturated_weight = soil["sat"]
    soil_type.soil_weight_parameters.unsaturated_weight = soil["unsat"]
    
    # WORKAROUND for bug in geolib
    # soil_type.undrained_parameters.undrained_shear_strength = 1
    
    model.add_soil(soil_type)

Markupsafe ImportError 'soft_unicode' when installing Geolib using pypi or requirements.txt

Installing Geolib and its dependencies from either pypi (pip install d-geolib) or from Github directly results in an incorrect version of Markupsafe to be installed. Markupsafe v2.0.1 is specified in requirements.txt, but somehow v2.1.1 is installed. This results in the following error when importing Geolib:

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (c:\ProgramData\Anaconda3\envs\test5\lib\site-packages\markupsafe\__init__.py)

Apparently, soft_unicode was removed in Markupsafe v2.1.0, causing the ImportError.

Installation using the Poetry pyproject.toml file does result in v2.0.1 and therefore does not cause an error

Bug in parsing sheet piling using SheetPiling.parse_text

GEOLib version 1.0.0

When trying to parse the sheet piling data as generated by the DSheetPilingStructure().parse_text("input file").input_data.sheet_piling to a SheetPiling instance using SheetPiling.parse_text(), Python throws a ValueError. This is due to the fact that the SheetPiling superclass (DSeriesStructureCollection) parse_text function allows for 1 field in the collection, while a SheetPiling defines 3. So irrespective of the input a ValueError is raised because len(fields) != 1 with fields = [('sheetpiling', <class 'types.ConstrainedListValue'>), ('leveltopsheetpiling', <class 'geolib.models.dsheetpiling.internal.ConstrainedFloatValue'>), ('lengthsheetpiling', <class 'geolib.models.dsheetpiling.internal.ConstrainedFloatValue'>)]

from geolib.models.dsheetpiling.internal import DSheetPilingStructure, SheetPileElement, SheetPiling
        
        with open(self.path + self.file) as f:
            text = f.read()

        d_sheet_file = DSheetPilingStructure.parse_text(text)

        sheet_text = d_sheet_file.input_data.sheet_piling
        sheet = SheetPiling.parse_text(sheet_text)


File "C:\Users\..\main.py", line 91, in read_file
        sheet = SheetPiling.parse_text(sheet_text)
File "C:\Users\..\lib\site-packages\geolib\models\dseries_parser.py", line 725, in parse_text
        raise ValueError(
ValueError: This type of collection is only meant to have one field but 3 were defined.

DStability - Shapely accuracy leads to invalid new layers

In the current version of geolib adding new layers to a DStability geometry can lead to errors in the geometry. This seems to be related to the accuracy of the coordinates. Here is an example of a layer that has been added programmatically;

01

As you can see the rightmost point of the new layer is not connected to the geometry which leads to an error if you want to calculate this using DStability.

Support BytesIO object for serialization

Hi GEOLib team,

As a developer I would like GEOLib to support serialization to an in memory BytesIO buffer. At this moment it is only possible to save the generated d-series input files to a file on the local file storage. At VIKTOR, we and our customers (the users of the D-series software) use GEOLib a lot within VIKTOR applications. With the current implementation in GEOLib, workarounds are needed to handle the generated d-series input files in memory and for example serve them as file downloads from the browser or calculate them on a local machine or remote server using VIKTOR. Sinds these applications are hosted on a remote server.

Supporting BytesIO buffers for serialization of the models will solve this problem.

DStability files cannot be read in Linux

Originally reported by Thijs Damsma

geolib cannot read all of the contents of *.stix files created with DStability when run under Linux. The root cause is probably in DSTability itself, using as it seems it uses mixed / and \ when creating the zipfiles. Compare the results of listing the same example.stix file in both windows:

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipfile
>>>
>>> print("\n".join(sorted(zipfile.ZipFile("example.stix", "r").namelist())))
calculationsettings/calculationsettings.json
calculationsettings/calculationsettings_1.json
calculationsettings/calculationsettings_2.json
calculationsettings/calculationsettings_3.json
checksum
decorations/decorations.json
decorations/decorations_1.json
decorations/decorations_2.json
decorations/decorations_3.json
geometries/geometry.json
geometries/geometry_1.json
geometries/geometry_2.json
geometries/geometry_3.json

and in linux:

Python 3.9.7 (default, Sep 22 2021, 12:06:37)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipfile
print("\n".join(sorted(zipfile.ZipFile("example.stix", "r").namelist())))
>>>
>>> print("\n".join(sorted(zipfile.ZipFile("example.stix", "r").namelist())))
calculationsettings/calculationsettings.json
calculationsettings\calculationsettings_1.json
calculationsettings\calculationsettings_2.json
calculationsettings\calculationsettings_3.json
checksum
decorations/decorations.json
decorations\decorations_1.json
decorations\decorations_2.json
decorations\decorations_3.json
geometries/geometry.json
geometries\geometry_1.json
geometries\geometry_2.json
geometries\geometry_3.json

Not 100 sure if the bug is in DSettelement writing a zipfile that is not to spec, or in the linux python zipfile implementation.

The code below outputs a fixed .stix file with only / as path separator, that is what I use as a workaround for now

from pathlib import Path
import zipfile


def fix_stix(p: Path):
    with zipfile.ZipFile(
        p.with_stem(p.stem + " - fixed"),
        mode="w",
        compression=zipfile.ZIP_DEFLATED,
    ) as dst:
        with zipfile.ZipFile(p, "r") as src:
            for file in src.namelist():
                dst.writestr(file.replace("\\", "/"), src.read(file))

Inconsistency in use of stage_index in geolib\models\dstability\internal.py

I have found an issue when adding consolidations to soil layers in D-Stability using the function add_soil_layer_consolidations(). The error that I get is No soil layer loads found for scenario 1 stage 0.

I think the issue originates in the function has_soil_layer() in geolib\models\dstability\internal.py on line 2312. This function expects the stage_index to be the index of the list of all stages, while the stage_index that is passed is the index of the list of stages in the scenario.

To fix the issue, I think a conversion of the stage_index is needed. I managed to get the adding of the consolidation values to work by adding the following line of code in geolib\models\dstability\internal.py on line 2316:
stage_index = sum([len(scenario.Stages) for scenario in self.scenarios[:scenario_index]]) + stage_index
I am not sure to what extend this impacts other parts of geolib.

Can this be fixed in the next version? I am currently using d-geolib version 1.3.1

Wrong waternet coordinate sequence in D-Stability

In some situations the waterline (or reference line) has a vertically oriented line segment. For instance a line with the following points: (-200, 1), (0, 1), (0, 5), (200, 5). If I define a reference line in a D-Stability model with the method add_reference_line, the order of the points seems to be correct in the DStabilityModel instance. However, when serializing to a .stix file and opening this file, the points are swapped to (-200, 1), (0, 5), (0, 1), (200, 5).

image
image

Is it possible to keep the order as defined in the .stix file? Thanks in advance.

D-Sheet Piling does not allow LoadType: DSHEETPILING_DETERMINED for UniformLoad and SurchargeLoad

The UniformLoad and SurchargeLoad raise a ValidationError when the LoadType is set to DSHEETPILING_DETERMINED.
This is caused by the following:

The 'UniformLoad' object uses the 'VerificationLoadSettings' object

class UniformLoad(BaseDataClass):
    """Uniform Load. This option is not available for SignlePileModelType.

    Args:
        name: Name of the SurchargeLoad.
        left_load: Value of the load on the left side.
        right_load: Value of the load on the right side.
        verification_load_settings: VerificationLoadSettings.
        standard_deviation_left: Standard deviation of the distribution type of the left side.
        standard_deviation_right: Standard deviation of the distribution type of the right side.
        distribution_type_left: Distribution type of the left side.
        distribution_type_right: Distribution type of the right side.
    """

    name: constr(min_length=1, max_length=50)
    left_load: float
    right_load: float
    verification_load_settings: VerificationLoadSettings = VerificationLoadSettings()

The VerificationLoadSettingsobject uses the 'LoadTypeFavourableUnfavourableMoment ' enum object for load type

class VerificationLoadSettings(BaseDataClass):
    """
    Load class for moment loads
    These options are available only if the Verification (EC7/CUR) option is selected in the Model window for the D-SheetPiling model.
    For GEOLIB the "verification" parameter should be set to True in the function DSheetPilingModel.set_model

    Args:
        duration_type: Select the duration of load application, Permanent or Variable.
        load_type: Select the type of load, Favorable or Unfavorable.
    """

    load_type: LoadTypeFavourableUnfavourableMoment = (
        LoadTypeFavourableUnfavourableMoment.FAVOURABLE
    )
    duration_type: LoadTypePermanentVariable = LoadTypePermanentVariable.PERMANENT

The 'LoadTypeFavourableUnfavourableMoment' object does not allow the DSHEETPILING_DETERMINED option.

class LoadTypeFavourableUnfavourableMoment(IntEnum):
    FAVOURABLE = 1
    UNFAVOURABLE = 2

The same holds for the SurchargeLoad. In D-Sheet Piling itself, this option is allowed for Uniform and Surcharge loads:

image

Issue(DStability): add_soil()-method returns the added Soil-object's Code instead of Id.

Per the documentation and docstring, the add_soil()-method of dstability_model.py returns: int: id of the added soil (L236).

"""
Add a new soil to the model. The code must be unique, the id will be generated
Args:
soil (Soil): a new soil
Returns:
int: id of the added soil
"""

However, the method returns the Soil-object's Code-attribute instead of its Id-attribute:

return persistant_soil.Code

Steps to Reproduce

  1. Define a D-Stability model using model_object = geolib.models.DStabilityModel()
  2. Add a new soil to model_object and assign the return to variable added_soil using added_soil = model_object.add_soil(new_soil)
  3. Check value of added_soil

D-SheetPiling factors are not filled in correctly in file.

Expected behaviour

The partial factors in the D-Sheetmodel are filled based on the default values when generating a D-Sheet model with the geolib api.

Observed behaviour

The constructive load factors from the partial factors are all 1 when generating the file.

image

Context

I believe this can be fixed by changing the template at : geolib/models/dsheetpiling/templates/input.shi.j2. But I am not sure exactly how to do that.

Problem with the DFoundationsModel().parse() function

Hi,

We would like to use the GEOLib package in our applications. Currently we use the VIKTOR/SDK Dfoundation bindings, but we would like to transfer to GEOLib. I have been trying to implement the package into one of our applications. The model creation and the execution works fine. Also an output file .fod can be created containing the correct information. Hoewever if I try to parse the fod file with:

parsed_file = DFoundationsModel().parse(filename=path)

I get the following error message:

  File "geolib/models/base_model.pyx", line 151, in geolib.models.base_model.BaseModel.parse
  File "geolib/models/parsers.pyx", line 61, in geolib.models.parsers.BaseParserProvider.parse
  File "geolib/models/dseries_parser.pyx", line 1146, in geolib.models.dseries_parser.DSerieParser.parse
  File "geolib/models/dseries_parser.pyx", line 1147, in geolib.models.dseries_parser.DSerieParser.parse
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 98, in geolib.models.dseries_parser.DSeriesStructure.__init__
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 98, in geolib.models.dseries_parser.DSeriesStructure.__init__
  File "geolib/models/dseries_parser.pyx", line 158, in geolib.models.dseries_parser.DSeriesStructure.parse_text
  File "geolib/models/dseries_parser.pyx", line 75, in geolib.models.dseries_parser.DSeriesStructure.__init__
ValueError: Got more fields than defined on model DFoundationsInputStructure:
                parser has {'user_classification_method'} fields and
                model has set() fields not set.

Do you know what I do wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.