-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slamd update 3 dichtebasierte angaben beim blending #125
base: main
Are you sure you want to change the base?
Changes from all commits
525a3b6
ae29476
4387ec1
76f3cd3
de1a229
a6b8676
1dc656f
ee4ca85
a28e2d4
704c449
c19f45b
ef80f16
d46a8e1
dec3485
0cba437
ae3dc30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,5 @@ | |
"mn2_o3": "10", | ||
"loi": "10", | ||
"fine": "10", | ||
"gravity": "10", | ||
"submit": "6 - Save material" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,5 @@ | |
"mn2_o3": "10", | ||
"loi": "10", | ||
"fine": "10", | ||
"gravity": "10", | ||
"submit": "6 - Save material" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,6 @@ def create_min_max_form(cls, material_type, count, base_material_uuids): | |
for _ in range(count): | ||
min_max_form.all_min_max_entries.append_entry() | ||
|
||
# Min/Max of the last entry are calculated from the previous entries, and the labels need to be switched | ||
min_max_form.all_min_max_entries[-1].min.label.text = 'Max (%)' | ||
min_max_form.all_min_max_entries[-1].max.label.text = 'Min (%)' | ||
|
||
return min_max_form, complete | ||
|
||
@classmethod | ||
|
@@ -99,24 +95,31 @@ def save_blended_materials(cls, submitted_blending_configuration): | |
|
||
base_materials_as_dict = [] | ||
base_type = submitted_blending_configuration['base_type'] | ||
blending_strategy = submitted_blending_configuration['blending_strategy'] | ||
base_materials_as_string = '' | ||
|
||
for base_material_uuid in base_material_uuids: | ||
base_material = MaterialsPersistence.query_by_type_and_uuid(base_type, base_material_uuid) | ||
if base_material is None: | ||
raise MaterialNotFoundException('The requested base materials do no longer exist!') | ||
base_materials_as_dict.append(base_material.__dict__) | ||
base_materials_as_string += base_material.name + '/' | ||
|
||
list_of_normalized_ratios_lists = RatioParser.create_list_of_normalized_ratio_lists(all_ratios_as_string, | ||
RATIO_DELIMITER) | ||
|
||
print(list_of_normalized_ratios_lists) | ||
print(base_materials_as_dict) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug print statements können raus |
||
if blending_strategy == 'Volume-based': | ||
list_of_normalized_ratios_lists = RatioParser.weight_to_density_ratios(list_of_normalized_ratios_lists, | ||
base_materials_as_dict) | ||
strategy = MaterialFactory.create_strategy(base_type.lower()) | ||
|
||
for ratio_list in list_of_normalized_ratios_lists: | ||
if len(ratio_list) != len(base_materials_as_dict): | ||
raise ValueNotSupportedException('Ratios cannot be matched with base materials!') | ||
|
||
blend_name = submitted_blending_configuration['blended_material_name'] | ||
blended_material_name = f'{blend_name}-{RatioParser.ratio_list_to_ratio_string(ratio_list)}' | ||
blended_material_name = f'{blend_name}-{blending_strategy}-{base_materials_as_string[:-1]}-{RatioParser.ratio_list_to_ratio_string(ratio_list)}' | ||
blended_material = strategy.create_blended_material(blended_material_name, ratio_list, | ||
base_materials_as_dict) | ||
strategy.save_model(blended_material) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
POWDER_DEFAULT_DENSITY = 1.40 | ||
LIQUID_DEFAULT_DENSITY = 1.00 | ||
AGGREGATE_DEFAULT_DENSITY = 2.40 | ||
ADMIXTURE_DEFAULT_DENSITY = 1.10 | ||
POWDER_DEFAULT_DENSITY = 3.15 | ||
LIQUID_DEFAULT_DENSITY = 1.05 | ||
AGGREGATE_DEFAULT_DENSITY = 2.65 | ||
ADMIXTURE_DEFAULT_DENSITY = 1.50 | ||
CUSTOM_DEFAULT_DENSITY = 1.00 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ class Composition: | |
@dataclass | ||
class Structure: | ||
fine: float = None | ||
gravity: float = None | ||
|
||
|
||
@dataclass | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,20 @@ def _to_normalized_ratio_list(cls, ratio, delimiter): | |
ratio_list = [string_to_number(piece) for piece in pieces] | ||
sum_ratio_list = sum(ratio_list) | ||
return [ratio / sum_ratio_list for ratio in ratio_list] | ||
|
||
@classmethod | ||
def weight_to_density_ratios(cls, normalized_ratios, base_materials): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diese Funktion nimmt Volumen-Ratios, wandelt sie durch Multiplikation mit Dichte in Massen-Ratios um, und renormalisiert dann diese, richtig? Wäre also ein Name wie "volume_to_weight_ratios" nicht passender? (Und ggf. "weight_ratio" als variablenname besser als "density ratio") |
||
densities = [base_material['density'] for base_material in base_materials] | ||
normalized_density_ratios = [] | ||
|
||
for normalized_ratio in normalized_ratios: | ||
weighted_ratios = [float(density) * float(ratio) for density, ratio in zip(densities, normalized_ratio)] | ||
sum_density_ratios = sum(weighted_ratios) | ||
|
||
normalized_density_ratio = [round(weighted / sum_density_ratios, 2) for weighted in weighted_ratios] | ||
normalized_density_ratios.append(normalized_density_ratio) | ||
|
||
return normalized_density_ratios | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verständnisfrage: Wo werden material_type und count im min_max_form template verwendet?