酸碱中和滴定

酸碱中和滴定 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 5 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.)


Info tab cannot be displayed because of an encoding error

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). Acid-Base Neutralization Titration. School of Chemistry and Chemical Engineering, Shaanxi Normal University.
breed [ waters water ]                ;; water molecules
breed [ hydroxides hydroxide ]        ;; base molecules
breed [ hydroniums hydronium ]        ;; acid molecules
breed [mode2_ch3coo_s mode2_ch3coo_]  ;;ch3coo_ molecules
breed [mode2_ch3coohs mode2_ch3cooh]  ;;ch3cooh molecules
breed [mode2_cl_s mode2_cl_]  ;;ch3coo_ molecules
breed [mode2_h_s mode2_h_]  ;;ch3cooh molecules
breed [mode2_na_s mode2_na_]  ;;ch3coo_ molecules
breed [mode2_oh_s mode2_oh_]  ;;ch3cooh molecules
breed [mode2_waters mode2_water]  ;;ch3cooh molecules

globals [
  base-added
  pH
  Strong_Co
  Weak_Co
  Base_Co
  Strong_PH
  Weak_PH
  Max_acid      ;;当前的酸
  Max_base      ;;当前最大的碱量
  Cur_base      ;;当前加到的碱量
  Limit_base    ;;最大计算的量,与图的x_MAX保持一致,现在为40
  drowing?
  cHAc_v
  cAc_v
  cNa+
  cCl-
  cH+
  cOH-
]

to setup
  clear-all

  ;一起
  if acid_switch = "together"[
    set Strong_Co 0.1
    set Weak_Co 0.1
  ]
  ;初始化强酸、弱酸、碱、初始加的碱浓度
  set base-added 0
  set Base_Co 0.1
  ;初始化最大酸量、当前碱量、最大碱量
  set Limit_base 40
  set Max_acid vol-acid
  set Cur_base 0
  set Max_base 0

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

  set-default-shape mode2_ch3coo_s "mode2_ch3coo_"
  set-default-shape mode2_ch3coohs "mode2_ch3cooh"
  set-default-shape mode2_cl_s "mode2_cl_"
  set-default-shape mode2_h_s "mode2_h_"
  set-default-shape mode2_na_s "mode2_na_"
  set-default-shape mode2_oh_s "mode2_oh_"
  set-default-shape mode2_waters "mode2_water"

  ;画图
  set drowing? false
  ;强酸部分
  if acid_switch = "Strong acid" [
    output-print "    HCl+NaOH=NaCl+H2O   "
    set Strong_Co 0.1
    calculate-pH
    ;创建酸
    ;    create-mode2_cl_s (5 * vol-acid)
    ;    [
    ;      setxy random-xcor random-ycor
    ;      set color (yellow - 0.4)
    ;      set size 0.8
    ;    ]
    create-mode2_h_s (5 * vol-acid)
    [
      setxy random-xcor random-ycor
      set size 2
    ]
  ]
  ;弱酸部分
  if acid_switch = "Weak acid"[
    output-print "CH3COOH+NaOH=CH3COONa+H2O"
    set Weak_Co 0.1
    calculate-pH
    ;初始化创建弱酸画图醋酸分子
    create-mode2_ch3coohs ((ceiling (5 * vol-acid * calculate_Weak_acid_HAC_derta)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode2_ch3coo_s ((ceiling (5 * vol-acid * calculate_Weak_acid_AC_derta)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
    create-mode2_h_s ((ceiling (5 * vol-acid * calculate_Weak_acid_AC_derta)))
    [
      setxy random-xcor random-ycor
      set size 2
    ]
  ]

  reset-ticks
end 

to go
  if ticks mod 1 = 0 [
    ;强酸部分动态图
    if acid_switch = "Strong acid" [
      react
      ask turtles
      [ fd 1                                        ;; move turtles around randomly
        rt random 360
        lt random 360 ]    ;; around the world
    ]
    ;弱酸部分动态图
    if acid_switch = "Weak acid"[
      HAC_resolve
      react
      ask turtles
      [ fd 1                                        ;; move turtles around randomly
        rt random 360
        lt random 360 ]    ;; around the world
    ]
  ]

  calculate-pH

  ;画图部分动态增加
  ifelse Cur_base < Limit_base [;40最大限制
    ifelse ((Cur_base * 100) / 100) < Max_base[;加碱量限制
      set drowing? true
      ifelse ((round (Cur_base * 100) / 100)  mod 1 = 0) [
        add_base_turtle 5
      ][]
      set Cur_base  (Cur_base + 0.05)
    ][ set drowing? false ]
  ][set drowing? false]

  if acid_switch = "Weak acid"[
    set cHAc_v  ( (precision ((10 ^ (- Weak_PH)) / ((10 ^ (- Weak_PH)) + 0.0000175)) 30 )* ( (  Max_acid  * Weak_Co ) / ( Cur_base + Max_acid ) ) )
    set cAc_v ( (precision (0.0000175 / ((10 ^ (- Weak_PH)) + 0.0000175)) 30 )* ( (  Max_acid  * Weak_Co ) / ( Cur_base + Max_acid ) ) )
    set cNa+ ( (  Cur_base  * Base_Co ) / ( Cur_base + Max_acid ) )
    set cH+ (10 ^(- Weak_PH))
    set cOH- ((10 ^(-14))/ cH+ )
  ]

if acid_switch = "Strong acid"[
    set cNa+ ( (  Cur_base  * Base_Co ) / ( Cur_base + Max_acid ) )
    set cCl- ( (  Max_acid  * Strong_Co ) / ( Cur_base + Max_acid ) )
    set cH+ (10 ^(- Strong_PH))
    set cOH- ((10 ^(-14))/ cH+ )
  ]
  tick
end 

;; adds hydroxide molecules to the solution

to add-base
  ifelse (Max_base + vol-base) <= Limit_base[
    set Max_base Max_base + vol-base
    set drowing? true
  ][set drowing? false]
end 

to add_base_turtle [number]
  if acid_switch = "Strong acid"[
  create-mode2_oh_s number
  [ set size 2
    fd 1 ]
  ]
  if acid_switch = "Weak acid"[
  create-mode2_oh_s number
  [ set size 1.5
    fd 1 ]
  ]
end 

;; hydroxide procedure

to react
  if acid_switch = "Strong acid"[
    if ( Strong_PH < 1.5) [
      ask mode2_h_s [
        let meeting-mode2_oh_s mode2_oh_s in-radius 2
        if count meeting-mode2_oh_s > 0 [
          ; 在半径2的范围内相遇时,创建新的mode2_waters turtle
          let turtles-here-mode2_h_s turtles with [breed = mode2_h_s]
          let turtles-here-mode2_oh_s turtles with [breed = mode2_oh_s]
          let turtle_mode2_h_s one-of turtles-here-mode2_h_s in-radius 2
          let turtle_mode2_oh_s one-of turtles-here-mode2_oh_s in-radius 2
          if turtle_mode2_h_s != nobody and turtle_mode2_oh_s != nobody [
            ask turtle_mode2_h_s [
              set breed mode2_waters
              set size 2
            ]
            ; 删除原来的mode2_oh_s turtle
            ask turtle_mode2_oh_s [
              die
            ]
          ]
        ]
      ]
    ]
    if ( Strong_PH > 1.5) and ( Strong_PH < 6 )[
      ask mode2_h_s [
        let meeting-mode2_oh_s mode2_oh_s in-radius 10
        if count meeting-mode2_oh_s > 0 [
          ; 在半径2的范围内相遇时,创建新的mode2_waters turtle
          let turtles-here-mode2_h_s turtles with [breed = mode2_h_s]
          let turtles-here-mode2_oh_s turtles with [breed = mode2_oh_s]
          let turtle_mode2_h_s one-of turtles-here-mode2_h_s in-radius 5
          let turtle_mode2_oh_s one-of turtles-here-mode2_oh_s in-radius 5
          if turtle_mode2_h_s != nobody and turtle_mode2_oh_s != nobody [
            ask turtle_mode2_h_s [
              set breed mode2_waters
              set size 2
            ]
            ; 删除原来的mode2_oh_s turtle
            ask turtle_mode2_oh_s [
              die
            ]
          ]
        ]
      ]
    ]
    if ( Strong_PH > 6) and ( Strong_PH <= 7)[
      ask mode2_oh_s [
        set breed mode2_waters
        set size 2
      ]
      ask mode2_h_s [
        die
      ]
    ]
  ]
  if acid_switch = "Weak acid"[
    if ( Weak_PH < 3) [
      ask mode2_h_s [
        let meeting-mode2_oh_s mode2_oh_s in-radius 2
        if count meeting-mode2_oh_s > 0 [
          ; 在半径2的范围内相遇时,创建新的mode2_waters turtle
          let turtles-here-mode2_h_s turtles with [breed = mode2_h_s]
          let turtles-here-mode2_oh_s turtles with [breed = mode2_oh_s]
          let turtle_mode2_h_s one-of turtles-here-mode2_h_s in-radius 2
          let turtle_mode2_oh_s one-of turtles-here-mode2_oh_s in-radius 2
          if turtle_mode2_h_s != nobody and turtle_mode2_oh_s != nobody [
            ask turtle_mode2_h_s [
              set breed mode2_waters
              set size 1.5
            ]
            ; 删除原来的mode2_oh_s turtle
            ask turtle_mode2_oh_s [
              die
            ]
          ]
        ]
      ]
    ]
    if ( Weak_PH > 3) and ( Weak_PH < 6 )[
      ask mode2_h_s [
        let meeting-mode2_oh_s mode2_oh_s in-radius 10
        if count meeting-mode2_oh_s > 0 [
          ; 在半径2的范围内相遇时,创建新的mode2_waters turtle
          let turtles-here-mode2_h_s turtles with [breed = mode2_h_s]
          let turtles-here-mode2_oh_s turtles with [breed = mode2_oh_s]
          let turtle_mode2_h_s one-of turtles-here-mode2_h_s in-radius 5
          let turtle_mode2_oh_s one-of turtles-here-mode2_oh_s in-radius 5
          if turtle_mode2_h_s != nobody and turtle_mode2_oh_s != nobody [
            ask turtle_mode2_h_s [
              set breed mode2_waters
              set size 1.5
            ]
            ; 删除原来的mode2_oh_s turtle
            ask turtle_mode2_oh_s [
              die
            ]
          ]
        ]
      ]
    ]
    if ( Weak_PH > 6) and ( Weak_PH <= 8.3)[
      ask mode2_oh_s [
        set breed mode2_waters
        set size 1.5
      ]
      ask mode2_h_s [
        die
      ]
    ]
  ]
end 

;; calculates the pH from the amount of the various ions in solution;
;; note that for simplicity the calculations don't take the true molar
;; concentration of water into account, but instead use an arbitrarily
;; chosen factor of 1000 to produce numbers lying in a reasonable range

to calculate-pH
  ;强酸部分
  if acid_switch != "Weak acid" [
    ifelse Cur_base = 0 [
      calculate_Strong_acid_ph_VBase0
    ][]
    ifelse (Cur_base > 0) and (Cur_base < Max_acid - 0.05)[
      calculate_Strong_acid_ph_VBase_less_Vacid
    ][]
    ifelse (Cur_base > 0) and (Cur_base >= Max_acid - 0.05) and (Cur_base <= Max_acid + 0.05) [
      calculate_Strong_acid_ph_VBase_equ_Vacid
    ][]
    ifelse (Cur_base > 0) and (Cur_base > Max_acid + 0.05)[
      calculate_Strong_acid_ph_VBase_greater_Vacid
    ][]
  ]
  ;弱酸部分
  if acid_switch != "Strong acid"[
    ifelse Cur_base = 0 [
      calculate_Weak_acid_ph_VBase0
    ][]
    ifelse (Cur_base > 0) and (Cur_base < 0.3 - 0.05)[
      calculate_Weak_acid_ph_03_VBase_less_Vacid
    ][]
    ifelse (Cur_base >= 0.3) and (Cur_base < Max_acid - 0.05)[
      calculate_Weak_acid_ph_VBase_less_Vacid
    ][]
    ifelse (Cur_base >= 0.3) and (Cur_base >= Max_acid - 0.05) and (Cur_base <= Max_acid + 0.05)[
      calculate_Weak_acid_ph_VBase_equ_Vacid
    ][]
    ifelse (Cur_base >= 0.3) and (Cur_base > Max_acid + 0.05)[
      calculate_Weak_acid_ph_VBase_greater_Vacid
    ][]
  ]

  if acid_switch != "together" [
  if (Cur_base > (Max_acid + 0.04)) and (Cur_base < (Max_acid + 1))[
    ask patches [
      set pcolor pink + 4.7
    ]
  ]
  if (Cur_base > (Max_acid + 1.04)) and (Cur_base < (Max_acid + 1.04 + 1))[
    ask patches [
      set pcolor pink + 4.7 - 0.2
    ]
  ]
  if (Cur_base > (Max_acid + 2.04)) and (Cur_base < (Max_acid + 2.04 + 1))[
    ask patches [
      set pcolor pink + 4.7 - 0.4
    ]
  ]
  if (Cur_base > (Max_acid + 3.04)) and (Cur_base < (Max_acid + 3.04 + 1))[
    ask patches [
      set pcolor pink + 4.7 - 0.6
    ]
  ]
  if (Cur_base > (Max_acid + 4.04)) and (Cur_base < (Max_acid + 4.04 + 1))[
    ask patches [
      set pcolor pink + 4.7 - 0.8
    ]
  ]
  if (Cur_base > (Max_acid + 5.04)) and (Cur_base < (Max_acid + 5.04 + 1))[
    ask patches [
      set pcolor pink + 4.7 - 1
    ]
  ]
    ]
end 


;;强酸计算:初始

to calculate_Strong_acid_ph_VBase0
  set Strong_PH (- (ln (Strong_Co) / ln 10))
end 

;;弱酸计算:初始

to calculate_Weak_acid_ph_VBase0
  set Weak_PH (- (ln ((sqrt (0.0000175 * 0.0000175 + 4 * 0.0000175 * Weak_Co ) - 0.0000175) / 2)/ ln 10))
end 

;;强酸计算:Vbase < Vacid

to calculate_Strong_acid_ph_VBase_less_Vacid
  set Strong_PH  (- (ln( (((Max_acid - Cur_base) * Strong_Co) / (Max_acid + Cur_base))) / ln 10))
end 

;;弱酸计算:Vbase < Vacid 且 Vbase < 0.3

to calculate_Weak_acid_ph_03_VBase_less_Vacid
  set Weak_PH (- (ln ((sqrt (0.0000175 * 0.0000175 + 4 * 0.0000175 * ((Weak_Co * Max_acid) / (Max_acid + Cur_base))) - 0.0000175) / 2)/ ln 10))
end 

;;弱酸计算:Vbase < Vacid

to calculate_Weak_acid_ph_VBase_less_Vacid
  set Weak_PH  (-(ln(0.0000175) / ln 10 ) + (ln ( Cur_base / ( Max_acid - Cur_base ) ) / ln 10))
end 

;;强酸计算:Vbase = Vacid

to calculate_Strong_acid_ph_VBase_equ_Vacid
  set Strong_PH 7
end 

;;弱酸计算:Vbase = Vacid

to calculate_Weak_acid_ph_VBase_equ_Vacid
  set Weak_PH  (14 + (ln ((sqrt ((0.0000000005714 * 0.0000000005714) + 4 * 0.0000000005714 * ((Weak_Co * Max_acid) / (Max_acid + Cur_base))) - 0.0000000005714) / 2 ) / ln 10))
end 

;;强酸计算:Vbase > Vacid

to calculate_Strong_acid_ph_VBase_greater_Vacid
  set Strong_PH (14 + (ln ( ( ( Cur_base - Max_acid ) * Base_Co ) / ( Cur_base + Max_acid ) ) / ln 10))
end 

;;弱酸计算:Vbase > Vacid

to calculate_Weak_acid_ph_VBase_greater_Vacid
  set Weak_PH (14 + (ln ( ( ( Cur_base - Max_acid ) * Base_Co ) / ( Cur_base + Max_acid ) ) / ln 10))
end 

;;弱酸画图所需的HAC分布系数

to-report calculate_Weak_acid_HAC_derta
  report precision  ((10 ^ (- Weak_PH)) / ((10 ^ (- Weak_PH)) + 0.0000175)) 2
end 

;;弱酸画图所需的AC分布系数

to-report calculate_Weak_acid_AC_derta
  report precision  (0.0000175 / ((10 ^ (- Weak_PH)) + 0.0000175)) 2
end 

;依据分布系数更新醋酸的量使其变成醋酸分子和氢

to HAC_resolve
  ;依据分布系数计算HAC数量
  let number (ceiling (5 * vol-acid * calculate_Weak_acid_HAC_derta))
  let cur_number count mode2_ch3coohs
  if number < cur_number[
    let resolve_number (cur_number - number)
    ask n-of resolve_number mode2_ch3coohs [
      set breed mode2_ch3coo_s
      set size 2
    ]
    create-mode2_h_s (resolve_number)
    [
      set size 2
    ]
  ]
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.