deltares / geolib Goto Github PK
View Code? Open in Web Editor NEWGEOLib: Python wrappers around the input and output files of the Deltares D-Serie models
Home Page: https://deltares.github.io/GEOLib/
License: MIT License
GEOLib: Python wrappers around the input and output files of the Deltares D-Serie models
Home Page: https://deltares.github.io/GEOLib/
License: MIT License
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.
!pip install d-geolib==0.1.6
from geolib import DFoundationsModel
ds = DFoundationsModel()
ds.parse(file)
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'
FYI: @martinapippi
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).
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?
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.
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.
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?
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
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`
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")
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'.
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
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.
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.
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.
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.
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.
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.
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()
Serialized model opened in D-Stability including running geolib.models.DStabilityModel().execute()
Steps to Reproduce
geolib.models.DStabilityModel().serialize()
the created model.geolib.models.DStabilityModel().execute()
the created model.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):
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")
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 %}
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.
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:
D-Geo Flow:
This issue is can be developed by the community if they deem this useful
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
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
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.
dm.output should be of type list and return the results of all stages
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
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,
The stochastic parameters should be filled in if provided
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?
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.
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/
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)
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
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.
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;
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.
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.
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))
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
Could the main branch be renamed to main to reflect cultural sensitivity and current standard of Git?
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)
.
Is it possible to keep the order as defined in the .stix file? Thanks in advance.
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:
Per the documentation and docstring, the add_soil()
-method of dstability_model.py
returns: int: id of the added soil
(L236).
GEOLib/geolib/models/dstability/dstability_model.py
Lines 229 to 237 in 9e0ea9c
However, the method returns the Soil-object's Code
-attribute instead of its Id
-attribute:
Steps to Reproduce
model_object = geolib.models.DStabilityModel()
model_object
and assign the return to variable added_soil
using added_soil = model_object.add_soil(new_soil)
added_soil
The partial factors in the D-Sheetmodel are filled based on the default values when generating a D-Sheet model with the geolib api.
The constructive load factors from the partial factors are all 1 when generating the file.
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.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.