多元弱酸分布曲线

多元弱酸分布曲线 preview image

1 collaborator

Default-person Ying Li (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 4 times • Downloaded 0 times • Run 0 times
Download the '多元弱酸分布曲线' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

; Li Ying created this module at Shaanxi Normal University in 2024. If you mention this model in a publication, we ask that you include the citations below.
;Ying, L. (2024). Multicomponent Weak Acid Distribution Curve. School of Chemistry and Chemical Engineering, Shaanxi Normal University.
breed [mode3_ac_s mode3_ac_]
breed [mode3_hacs mode3_hac]
breed [mode3_h2c2o4s mode3_h2c2o4]
breed [mode3_h2c2o4_s mode3_h2c2o4_]
breed [mode3_c2o4_s mode3_c2o4_]
breed [mode3_h3po4s mode3_h3po4]
breed [mode3_h2po4_s mode3_h2po4_]
breed [mode3_hpo4_s mode3_hpo4_]
breed [mode3_po4_s mode3_po4_]
breed [mode3_nh4s mode3_nh4]
breed [mode3_nh3_h2os mode3_nh3_h2o]

globals[
  cur_pH
  MAX_pH
  cur_number  ;显示几个线
  cur_value1  ;第一条线
  cur_value2  ;第一条线
  cur_value3  ;第一条线
  cur_value4  ;第一条线

  H           ;H+
  OH          ;OH-
  cur_value21
  cur_value22
  cur_value23
  cur_value24
]

to setup
  clear-all

  ;参数初始化
  set cur_pH 0

  ;设置画布颜色白色
  ask patches [
    set pcolor white
  ]

  ;初始化海龟
  set-default-shape mode3_ac_s "mode3_ac_"
  set-default-shape mode3_hacs "mode3_hac"
  set-default-shape mode3_h2c2o4s "mode3_h2c2o4"
  set-default-shape mode3_h2c2o4_s "mode3_h2c2o4_"
  set-default-shape mode3_c2o4_s "mode3_c2o4_"
  set-default-shape mode3_h3po4s "mode3_h3po4"
  set-default-shape mode3_h2po4_s "mode3_h2po4_"
  set-default-shape mode3_hpo4_s "mode3_hpo4_"
  set-default-shape mode3_po4_s "mode3_po4_"

  ;初始化图像
  if (Weak-acid = "Monobasic Weak-acid: 0.1M HAc")[
    set cur_number 2
    create-mode3_hacs ((ceiling (100 * Acetic_acid_molecular_calculation_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_ac_s ((ceiling (100 * Acetic_acid_ion_calculation_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
  ]
  if (Weak-acid = "Dibasic Weak-acid: 0.1M H2C2O4") [
    set cur_number 3
    create-mode3_h2c2o4s ((ceiling (100 * Molecular_calculation_formula_of_oxalic_acid)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_h2c2o4_s ((ceiling (100 * Formula_for_calculating_hydrogen_oxalate)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_c2o4_s ((ceiling (100 * Oxalate_calculation_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
  ]
  if (Weak-acid = "Terbasic Weak-acid: 0.1M H3PO4") [
    set cur_number 4
    create-mode3_h3po4s ((ceiling (100 * Phosphoric_acid_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_h2po4_s ((ceiling (100 * Dihydrogen_phosphate_root_calculation_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_hpo4_s ((ceiling (100 * Formula_for_calculating_mono_hydrogen_phosphate)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode3_po4_s ((ceiling (100 * Phosphate_group_calculation_formula)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
  ]

 reset-ticks
end 

to go
  update_line
  update_graph
  update_graph2

  if cur_pH  <  (SF - 0.001) [
    set cur_pH  (cur_pH + 0.01)
  ]
  print cur_pH
  ask turtles
  [ fd 1                                        ;; move turtles around randomly
    rt random 360
    lt random 360 ]
  print H/OH_switch
  tick
end 

;计算醋酸分子的derta

to-report Acetic_acid_molecular_calculation_formula
  report precision ((10 ^ (- cur_pH)) / ((10 ^ (- cur_pH)) + 0.0000175)) 30
end 

;计算醋酸离子的derta

to-report Acetic_acid_ion_calculation_formula
  report precision ((0.0000175) / ((10 ^ (- cur_pH)) + 0.0000175)) 30
end 

;计算草酸分子的derta

to-report Molecular_calculation_formula_of_oxalic_acid
  report precision ( ((10 ^ (- cur_pH)) ^ 2) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 30
end 

;计算草酸氢根的derta

to-report Formula_for_calculating_hydrogen_oxalate
  report precision ( (0.059 * (10 ^ (- cur_pH))) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 30
end 

;计算草酸根的derta

to-report Oxalate_calculation_formula
  report precision ( (0.059 * 0.000064) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 30
end 

;计算磷酸的derta

to-report Phosphoric_acid_formula
  report precision ( ((10 ^ (- cur_pH)) ^ 3) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30
end 

;计算磷酸二氢根的derta

to-report Dihydrogen_phosphate_root_calculation_formula
  report precision ( (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30
end 

;计算磷酸一氢根的derta

to-report Formula_for_calculating_mono_hydrogen_phosphate
  report precision ( (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30
end 

;计算磷酸根的derta

to-report Phosphate_group_calculation_formula
  report precision ( (0.0076 * 0.000000063 * 0.00000000000044) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30
end 

;计算一水合氨的derta

to-report Ammonia_monohydrate_calculation_formula
  report precision ( (0.00000000000001 / 0.000018) / ((10 ^ (- cur_pH)) + (0.00000000000001 / 0.000018)) ) 2
end 

;计算铵根的derta

to-report Ammonium_calculation_formula
  report precision ( (10 ^ (- cur_pH)) / ((10 ^ (- cur_pH)) + (0.00000000000001 / 0.000018)) ) 2
end 

;更新图像变化

to update_graph
  if (Weak-acid = "Monobasic Weak-acid: 0.1M HAc")[
    let temp_number count mode3_hacs
    if temp_number > (cur_value1 * 100)[
      let resolve_number (temp_number - (cur_value1 * 100))
      ask n-of resolve_number mode3_hacs [
        set breed mode3_ac_s
        set size 2
      ]
    ]
  ]
  if (Weak-acid = "Dibasic Weak-acid: 0.1M H2C2O4")[
    let temp_h2c2o4s count mode3_h2c2o4s
    if temp_h2c2o4s != (cur_value3 * 100)[
      ifelse temp_h2c2o4s > (cur_value3 * 100)[
        let resolve_number (temp_h2c2o4s - (cur_value3 * 100))
        ask n-of resolve_number mode3_h2c2o4s [
          die
        ]
      ][
        create-mode3_h2c2o4s ((cur_value3 * 100) - temp_h2c2o4s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]

    let temp_h2c2o4_s count mode3_h2c2o4_s
    if temp_h2c2o4_s != (cur_value1 * 100)[
      ifelse temp_h2c2o4_s > (cur_value1 * 100)[
        let resolve_number2 (temp_h2c2o4_s - (cur_value1 * 100))
        ask n-of resolve_number2 mode3_h2c2o4_s [
          die
        ]
      ][
        create-mode3_h2c2o4_s ((cur_value1 * 100) - temp_h2c2o4_s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]

    let temp_c2o4_s count mode3_c2o4_s
    if temp_c2o4_s != (cur_value2 * 100)[
      ifelse temp_c2o4_s > (cur_value2 * 100)[
        let resolve_number3 (temp_c2o4_s - (cur_value2 * 100))
        ask n-of resolve_number3 mode3_c2o4_s [
          die
        ]
      ][
        create-mode3_c2o4_s ((cur_value2 * 100) - temp_c2o4_s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]
  ]
  if (Weak-acid = "Terbasic Weak-acid: 0.1M H3PO4") [
    let temp_h3po4s count mode3_h3po4s
    if temp_h3po4s != (cur_value4 * 100)[
      ifelse temp_h3po4s > (cur_value4 * 100)[
        let resolve_number (temp_h3po4s - (cur_value4 * 100))
        ask n-of resolve_number mode3_h3po4s [
          die
        ]
      ][
        create-mode3_h3po4s ((cur_value4 * 100) - temp_h3po4s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]

    let temp_h2po4_s count mode3_h2po4_s
    if temp_h2po4_s != (cur_value3 * 100)[
      ifelse temp_h2po4_s > (cur_value3 * 100)[
        let resolve_number2 (temp_h2po4_s - (cur_value3 * 100))
        ask n-of resolve_number2 mode3_h2po4_s [
          die
        ]
      ][
        create-mode3_h2po4_s ((cur_value3 * 100) - temp_h2po4_s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]

    let temp_hpo4_s count mode3_hpo4_s
    if temp_hpo4_s != (cur_value1 * 100)[
      ifelse temp_hpo4_s > (cur_value1 * 100)[
        let resolve_number3 (temp_hpo4_s - (cur_value1 * 100))
        ask n-of resolve_number3 mode3_hpo4_s [
          die
        ]
      ][
        create-mode3_hpo4_s ((cur_value1 * 100) - temp_hpo4_s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]


    let temp_po4_s count mode3_po4_s
    if temp_po4_s != (cur_value2 * 100)[
      ifelse temp_po4_s > (cur_value2 * 100)[
        let resolve_number4 (temp_po4_s - (cur_value2 * 100))
        ask n-of resolve_number4 mode3_po4_s [
          die
        ]
      ][
        create-mode3_po4_s ((cur_value2 * 100) - temp_po4_s)
        [
          setxy random-xcor random-ycor
          set size 2
        ]
      ]
    ]
  ]
end 

;更新曲线变化

to update_line
  if (Weak-acid = "Monobasic Weak-acid: 0.1M HAc") [
    set cur_value1 Acetic_acid_molecular_calculation_formula  ;醋酸分子
    set cur_value2 Acetic_acid_ion_calculation_formula        ;醋酸离子
  ]
  if (Weak-acid = "Dibasic Weak-acid: 0.1M H2C2O4") [
    set cur_value3 Molecular_calculation_formula_of_oxalic_acid
    set cur_value1 Formula_for_calculating_hydrogen_oxalate
    set cur_value2 Oxalate_calculation_formula
  ]
  if (Weak-acid = "Terbasic Weak-acid: 0.1M H3PO4") [
    set cur_value4 Phosphoric_acid_formula
    set cur_value3 Dihydrogen_phosphate_root_calculation_formula
    set cur_value1 Formula_for_calculating_mono_hydrogen_phosphate
    set cur_value2 Phosphate_group_calculation_formula
  ]
end 

;更新下曲线变化

to update_graph2
  if (Weak-acid = "Monobasic Weak-acid: 0.1M HAc") [
    if H/OH_switch [
      let temp_h (10 ^ (- cur_pH))
      let temp_oh ( (10 ^ (-14)) / temp_h)
      set H ( (ln (temp_h) / ln 10))
      set OH ( (ln (temp_oh) / ln 10))
    ]
    set cur_value22 ( (ln ((precision ((10 ^ (- cur_pH)) / ((10 ^ (- cur_pH)) + 0.0000175)) 10) * 0.1) / ln 10))
    set cur_value21 ( (ln ((precision ((0.0000175) / ((10 ^ (- cur_pH)) + 0.0000175)) 10) * 0.1) / ln 10))
  ]
  if (Weak-acid = "Dibasic Weak-acid: 0.1M H2C2O4") [
    if H/OH_switch[
      let temp_h (10 ^ (- cur_pH))
      let temp_oh ( (10 ^ (-14)) / temp_h)
      set H ( (ln (temp_h) / ln 10))
      set OH ( (ln (temp_oh) / ln 10))
    ]
    set cur_value23 ( (ln ((precision ( ((10 ^ (- cur_pH)) ^ 2) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 30) * 0.1) / ln 10))
    set cur_value22 ( (ln ((precision ( (0.059 * (10 ^ (- cur_pH))) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 10) * 0.1) / ln 10))
    set cur_value21 ( (ln ((precision ( (0.059 * 0.000064) / (((10 ^ (- cur_pH)) ^ 2) + (0.059 * (10 ^ (- cur_pH))) + (0.059 * 0.000064)) ) 10) * 0.1) / ln 10))
  ]
  if (Weak-acid = "Terbasic Weak-acid: 0.1M H3PO4") [
    if H/OH_switch[
      let temp_h (10 ^ (- cur_pH))
      let temp_oh ( (10 ^ (-14)) / temp_h)
      set H ( (ln (temp_h) / ln 10))
      set OH ( (ln (temp_oh) / ln 10))
    ]
    set cur_value24 ( (ln ((precision ( ((10 ^ (- cur_pH)) ^ 3) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30) * 0.1) / ln 10))
    set cur_value23 ( (ln ((precision ( (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 10) * 0.1) / ln 10))
    set cur_value22 ( (ln ((precision ( (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 10) * 0.1) / ln 10))
    set cur_value21 ( (ln ((precision ( (0.0076 * 0.000000063 * 0.00000000000044) / (((10 ^ (- cur_pH)) ^ 3) + (0.0076 * ((10 ^ (- cur_pH)) ^ 2)) + (0.0076 * 0.000000063 * (10 ^ (- cur_pH))) + (0.0076 * 0.000000063 * 0.00000000000044)) ) 30) * 0.1) / ln 10))
  ]
end 

There is only one version of this model, created 15 days ago by Ying Li.

Attached files

File Type Description Last updated
多元弱酸分布曲线.png preview Preview for '多元弱酸分布曲线' 15 days ago, by Ying Li Download

This model does not have any ancestors.

This model does not have any descendants.