Created
March 30, 2023 16:06
-
-
Save kks32/610ea67cf804a15d9e3a975228bb87c1 to your computer and use it in GitHub Desktop.
GPT-3.5 USCS Soil Classification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prompt: Write a python code for USCS soil classification | |
# | |
# Output: | |
# USCS Soil Classification | |
# Based on ASTM D2487-17 Standard Practice for Classification of Soils for Engineering Purposes | |
# Enter soil properties | |
percent_gravel = float(input("Enter percent gravel: ")) | |
percent_sand = float(input("Enter percent sand: ")) | |
percent_fines = float(input("Enter percent fines (silt + clay): ")) | |
# Calculate soil classification | |
if percent_fines < 5: | |
if percent_gravel > 50: | |
print("Classification: GW - well-graded gravel") | |
elif percent_sand > 50: | |
print("Classification: SP - poorly-graded sand") | |
else: | |
print("Classification: GP - poorly-graded gravel") | |
elif percent_fines >= 5 and percent_fines < 12: | |
if percent_gravel > 50: | |
print("Classification: GM - silty gravel") | |
elif percent_sand > 50: | |
print("Classification: SM - silty sand") | |
else: | |
print("Classification: GP-GM - gravelly, sandy, or clayey silt") | |
elif percent_fines >= 12 and percent_fines < 50: | |
if percent_sand < 50: | |
print("Classification: CL - clay") | |
elif percent_gravel > percent_sand: | |
print("Classification: GC - clayey gravel") | |
else: | |
print("Classification: SC - clayey sand") | |
else: | |
if percent_sand < 50: | |
print("Classification: OL - organic soil") | |
else: | |
print("Classification: MH - highly organic silt or clay") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prompt: Write a python code for USCS soil classification using liquid limit and plastic limit | |
# USCS Soil Classification | |
# Based on ASTM D2487-17 Standard Practice for Classification of Soils for Engineering Purposes | |
# Enter soil properties | |
percent_gravel = float(input("Enter percent gravel: ")) | |
percent_sand = float(input("Enter percent sand: ")) | |
percent_fines = float(input("Enter percent fines (silt + clay): ")) | |
liquid_limit = int(input("Enter liquid limit: ")) | |
plastic_limit = int(input("Enter plastic limit: ")) | |
# Calculate soil classification | |
if percent_fines < 5: | |
if percent_gravel > 50 and (percent_sand <= 50 or liquid_limit >= 40): | |
print("Classification: GW - well-graded gravel") | |
elif percent_sand > 50 and (percent_gravel <= 50 or liquid_limit >= 40): | |
print("Classification: SP - poorly-graded sand") | |
elif liquid_limit < 50 and plasticity_index >= 4 and percent_sand > 15 and percent_fines < (10 * percent_sand): | |
print("Classification: SW - well-graded sand") | |
else: | |
print("Classification: GP - poorly-graded gravel") | |
elif percent_fines >= 5 and percent_fines < 12: | |
if percent_gravel > 50 and (percent_sand <= 50 or liquid_limit >= 40): | |
print("Classification: GM - silty gravel") | |
elif percent_sand > 50 and (percent_gravel <= 50 or liquid_limit >= 40): | |
print("Classification: SM - silty sand") | |
elif liquid_limit < 50 and plasticity_index >= 4 and percent_sand > 15 and percent_fines < (10 * percent_sand): | |
print("Classification: SW - well-graded sand") | |
else: | |
print("Classification: GP-GM - gravelly, sandy, or clayey silt") | |
elif percent_fines >= 12 and percent_fines < 50: | |
if liquid_limit >= 50 and plasticity_index >= 4 and percent_clay >= 50: | |
print("Classification: CL - lean clay") | |
elif liquid_limit >= 50 and plasticity_index >= 4 and (percent_clay < 50 or percent_sand > (2 * percent_clay)): | |
print("Classification: CL-ML - silt-clay") | |
elif percent_sand < 50 and percent_clay >= (30 * (percent_sand - 15)): | |
print("Classification: CH - clayey gravel") | |
elif percent_sand >= 50 and percent_clay >= (30 * (percent_sand - 15)): | |
print("Classification: SC - clayey sand") | |
else: | |
print("Classification: CL-ML - silt-clay") | |
else: | |
if percent_sand < 50 and (liquid_limit < 80 or plasticity_index < 10): | |
print("Classification: PT - peat") | |
elif percent_sand >= 50 and (liquid_limit < 80 or plasticity_index < 10): | |
print("Classification: MH - highly organic silt or clay") | |
elif liquid_limit >= 80 and plasticity_index >= 10: | |
print("Classification: OH - organic clay") | |
else: | |
print("Classification: OL - organic soil") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment